Improve Turing sample (#3040)

* Improve Turing sample

* Move more complex sample to different file

* Undo changes to original file
This commit is contained in:
Horatiu Lazu
2016-06-07 08:13:12 -04:00
committed by Arfon Smith
parent cbbc05f7b8
commit baf56666d4
2 changed files with 671 additions and 9 deletions

View File

@@ -1,19 +1,19 @@
% Accepts a number and calculates its factorial
function factorial (n: int) : real
if n = 0 then
result 1
else
result n * factorial (n - 1)
if n = 0 then
result 1
else
result n * factorial (n - 1)
end if
end factorial
var n: int
loop
put "Please input an integer: " ..
get n
exit when n >= 0
put "Input must be a non-negative integer."
put "Please input an integer: " ..
get n
exit when n >= 0
put "Input must be a non-negative integer."
end loop
put "The factorial of ", n, " is ", factorial (n)
put "The factorial of ", n, " is ", factorial (n)