;** Die Teiler einer Zahl/einfachster Primzahltest
;** 01.05.2005 by Triton, verbessert 22.10.2005
;** http://www.silizium-net.de
AppTitle("die Teiler ganzer Zahlen")
Graphics 800,600,32,2
zahl= 12582912
Locate 5,GraphicsHeight()-20
Print "Pfeiltasten links/rechts für Änderung der Zahl, ESC zum Beenden"
While Not KeyDown(1)
If KeyHit(205) Then ;r
Cls
zahl=zahl+1
x=0
y=0
a=0
End If
If KeyHit(203) Then ;l
Cls
zahl=zahl-1
x=0
y=0
a=0
End If
teiler(zahl)
Wend
WaitKey
;---
Function teiler(zahl)
For teiler=1 To zahl/2 ;für Primzahlen reicht sqr(zahl)
If zahl Mod teiler = 0 Then
Locate x,y
Print teiler
a=a+1
y=y+16
If a Mod 30=0 Then x=x+100:y=0
End If
Next
Locate x,y
a=a+1
Print zahl
Locate x,y+16
If a=2 Then Print a+" Teiler - die Zahl ist Prim!"
If a>2 Then Print a+" Teiler - die Zahl ist nicht Prim!"
Locate 5,GraphicsHeight()-20
End Function
|