'********************************************* '* PRIME NUMBERS * '* ----------------------------------------- * '* This small program tests if a given inte- * '* ger number is a prime number or not. * '* ----------------------------------------- * '* Ref.: "Mathematiques par l'informatique * '* individuelle (1) par H. Lehning * '* et D. Jakubowicz, Masson, Paris, * '* 1982" [BIBLI 06]. * '********************************************* 'See also program factors.bas cls print input " ? ", N print 'Test if multiple of 2 D=N-2*INT(N/2) if D=0 then goto 100 'Test if multiple of 3 D=N-3*INT(N/3) if D=0 then goto 100 'Test if multiple of 6i-1 and 6i+1 from i=6 to sqr(N)+1 For I%=6 to INT(SQR(N))+1 step 6 D=N-(I%-1)*INT(N/(I%-1)) if D=0 then goto 100 D=N-(I%+1)*INT(N/(I%+1)) if D=0 then goto 100 Next I% print " Prime number.":end 100 print " Not a prime number." end 'end of file prime.bas