Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
33
Task/Factorial/FutureBasic/factorial.futurebasic
Normal file
33
Task/Factorial/FutureBasic/factorial.futurebasic
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
include "ConsoleWindow"
|
||||
|
||||
local fn factorialIterative( n as long ) as double
|
||||
dim as double f
|
||||
dim as long i
|
||||
|
||||
if ( n > 1 )
|
||||
f = 1
|
||||
for i = 2 To n
|
||||
f = f * i
|
||||
next i
|
||||
else
|
||||
f = 1
|
||||
end if
|
||||
end fn = f
|
||||
|
||||
local fn factorialRecursive( n as long ) as double
|
||||
dim as double f
|
||||
|
||||
if ( n < 2 )
|
||||
f = 1
|
||||
else
|
||||
f = n * fn factorialRecursive( n -1 )
|
||||
end if
|
||||
end fn = f
|
||||
|
||||
dim as long i
|
||||
|
||||
for i = 0 to 12
|
||||
print "Iterative:"; using "####"; i; " ="; fn factorialIterative( i )
|
||||
print "Recursive:"; using "####"; i; " ="; fn factorialRecursive( i )
|
||||
print
|
||||
next i
|
||||
Loading…
Add table
Add a link
Reference in a new issue