-
Notifications
You must be signed in to change notification settings - Fork 67
Primes
Rebecca G. Bettencourt edited this page Aug 28, 2014
·
1 revision
Sample code to find prime numbers.
#!/usr/bin/xion
function isprime n
if n < 2 then return false
repeat with x = 2 to the sqrt of n
if n mod x == 0 then return false
end repeat
return true
end isprime
on primes cnt
repeat with x = 0 to cnt
if isprime(x) then
put x
end if
end repeat
end primes
ask "List primes up to:" with "50"
if it is not empty and the result is not "Cancel" then primes it
Home - Downloads - Installation - Sample Code