Home > Palm > Samples > Combination > Basic
 
  Palm sample in Basic

 Purpose

This is the Basic version of our combination application. It's one of the Palm Samples.

 Requirements

You need SmallBasic (see tools section).

 Source code

Below is the .bas file.

' Combination.bas
' Palm
' SmallBasic


func factorial(n)
local total


total = 1


if (n > 1) then
    for i = 2 to n
        total = total * i
    next i
endif

factorial = total
end

func combination(n, p)
    combination = factorial(n) / (factorial(n-p)*factorial(p))
end

print cat(3); "Combination > Palm > SmallBasic"; cat(0)
print
print "factorial(7) = "; factorial(7)
print "factorial(4) = "; factorial(4)
print "factorial(3) = "; factorial(3)

print "combination(7, 4) = "; combination(7, 4)

 Comments

SmallBasic runs on your mobile device.

Copy and Paste the source code above into a new memo with Palm Desktop. Run HotSync. The source code will be stored in a 'Combination.bas memo, that you can load and run with SmallBasic.

The core functions are : factorial(), combination() and the main program.

Next sample

 
[ Copyright © 2000- Eric Poncet - All rights reserved ]

[ Stage de musique classique | Stage de musique baroque | Stage de musique de chambre | Stage de musique latine ]
[ Stage de jazz | Stage de musiques actuelles | Stage de funk | Stage de metal | Stage de pop | Stage de reggae | Stage de rock ]
[ Stage d'improvisation | Colonie musicale ]