Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Learn more about F# at http://fsharp.org
- // See the 'F# Tutorial' project for more help.
- // The code for both koan and problem are included in this file
- // Indented code available at
- open System
- [<EntryPoint>]
- let main argv =
- // Koan
- // let dosomethingrandom x =
- // if x == 0 then Console.WriteLine(1)
- // else dosomethingrandom (x - 1) * x
- let rec dosomethingrandom x =
- if x = 0 then 1
- else x * dosomethingrandom (x - 1)
- let calc0 = dosomethingrandom 0
- let calc12 = dosomethingrandom 12
- printfn "%d %d" calc0 calc12
- // Problem
- printf "Enter name "
- let name = Console.ReadLine()
- printf "Enter age "
- let isvalid, age = Int32.TryParse(Console.ReadLine())
- if isvalid then
- let message = if age >= 20 then name + " is not a teenager"
- elif age < 13 then
- name + " is a kid or child"
- else
- name + " is a teenager"
- printfn "%s" message
- Console.ReadKey()
- 0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement