Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $num = 0
- $from = $CmdLine[1]
- $to = $CmdLine[2]
- $from = Round($from, 0)
- $to = Round($to, 0)
- $full = "Primzahlen von " & $from & " bis " & $to & @CRLF
- if $from = 1 then $from = 2
- if $to < $from then
- MsgBox(0, "Ähm...", "Von " & $from & " bis " & $to & "?" & @CRLF & "Wie soll das denn gehen?")
- Exit
- EndIf
- $timer = TimerInit()
- for $i = $from To $to
- $prim = 1
- for $u = 2 To $i-1
- $float = $i/$u
- if Round($float, 0) = $float then
- $prim = 0
- ExitLoop
- EndIf
- Next
- if $prim = 1 then
- ConsoleWrite("Primzahl: " & $i & @CRLF)
- $num = $num + 1
- $full = $full & $i & @CRLF
- EndIf
- Next
- FileDelete(@ScriptDir & "\prim.txt")
- $full = $full & @CRLF & @CRLF & $num & " Primzahlen in " & Round(TimerDiff($timer)/1000, 3) & " Sekunden gefunden"
- FileWrite(@ScriptDir & "\prim.txt", $full)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement