Factorial: Difference between revisions

Content added Content deleted
mNo edit summary
Line 1,493: Line 1,493:


==={{header|Craft Basic}}===
==={{header|Craft Basic}}===
<syntaxhighlight lang="basic">'factorial example
<syntaxhighlight lang="basic">'accurate between 1-12
'accurate between 1-12


print "version 1 without function"
let f = 1


for i = 1 to 12
alert "factorial"
input "enter an integer: ", n


let n = i
do
let f = 1


do
let f = f * n
let n = n - 1


let f = f * n
loop n > 0
let n = n - 1


loop n > 0
print f


print f, " ",
end</syntaxhighlight>
wait

next i

print newline, newline, "version 2 with function"

for i = 1 to 12

print factorial(i), " ",

next i</syntaxhighlight>
{{out| Output}}<pre>version 1 without function
1 2 6 24 120 720 5040 40320 362880 3628800 39916800 479001600

version 2 with function
1 2 6 24 120 720 5040 40320 362880 3628800 39916800 479001600 </pre>


==={{header|FreeBASIC}}===
==={{header|FreeBASIC}}===