(lab 5) feat: add Number Operations example

main
Artem-Darius Weber 3 weeks ago
parent 1a9fd26526
commit 90b3ef553b

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
</Project>

@ -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)
[<EntryPoint>]
let main argv =
System.Console.WriteLine("Введите число:")
let number = System.Console.ReadLine() |> int
let result = sumDigits number
System.Console.WriteLine($"Сумма цифр числа {number} равна {result}")
0
Loading…
Cancel
Save