File: function_factorial.kbs

package info (click to toggle)
basic256 2.0.99.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,888 kB
  • sloc: cpp: 17,185; yacc: 4,025; lex: 1,466; java: 1,091; sh: 39; xml: 33; makefile: 20
file content (16 lines) | stat: -rw-r--r-- 288 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# function test - Recursive function to calculate factorial
# 2012-10-04 j.m.reneau
# BASIC-256 version 0.9.6.74 or better

for n = 1 to 20
   print n + "! =" + fact(n)
next n
end

function fact(n)
   if n >=2 then
      fact = fact(n-1) * n
   else
      fact = 1
   end if
end function