// F#
open System;
[]
let main argv =
let rec getNumberFromConsole _ =
printf "Please enter a correct 4-digits number?\n"
let maybeInt = Console.ReadLine();
let mutable value = 0;
if Int32.TryParse(maybeInt, &value) && value >= 1000 && value <= 9999<br> then value
else (getNumberFromConsole null)
let rec power = function
| (x, 0) -> 1
| (x, n) -> x * power (x, n-1)
let getDigit sourceNumber digit =
(sourceNumber / (power (10, digit))) % 10
let number = getNumberFromConsole null
let resultNumber = getDigit number 0 * 1000 + getDigit number 1 * 100 + getDigit number 2 * 10 + getDigit number 3
printf "%d" resultNumber
Console.ReadKey true |> ignore
0