2.14. recurse.bas

[<<<] [>>>]

This program tests recursive function call of the simplest type. It actually does nothing, but calculates the number 10. It knows that 10 is assigned to 10 and that the number assigned to a number x < 10 is the same as the number assigned to x+1.

Example recurse.bas :

'
' This function calculates the number 10
' recursively
'
function Calculate10(x)

print "Starting calculate 10 for the number ",x,"\n"

if x = 10 then Calculate10 = x else Calculate10 = Calculate10(x+1) endif

print "Ending calculate 10 for the number ",x,"\n"

end function

Calculate10 1

Result executing recurse.bas :

Possible error messages sent to stderr:


[<<<] [>>>]