diff --git a/lab 5/NumberOperations/NumberOperations.fsproj b/lab 5/NumberOperations/NumberOperations.fsproj new file mode 100755 index 0000000..299cf40 --- /dev/null +++ b/lab 5/NumberOperations/NumberOperations.fsproj @@ -0,0 +1,12 @@ + + + + Exe + net7.0 + + + + + + + diff --git a/lab 5/NumberOperations/Program.fs b/lab 5/NumberOperations/Program.fs new file mode 100755 index 0000000..5a32dfd --- /dev/null +++ b/lab 5/NumberOperations/Program.fs @@ -0,0 +1,16 @@ +// For more information see https://aka.ms/fsharp-console-apps +printfn "Hello from F#" + +let rec sumDigits n = + if n < 10 then n + else (n % 10) + sumDigits (n / 10) + +[] +let main argv = + System.Console.WriteLine("Введите число:") + let number = System.Console.ReadLine() |> int + + let result = sumDigits number + System.Console.WriteLine($"Сумма цифр числа {number} равна {result}") + + 0