You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

36 lines
631 B

#!/usr/bin/env ferite
/* Ferite version of a Prime Number Finder
* haplo@mindstab.net */
uses "array", "console", "math";
array fncArgs;
number MAX, cnt, test, i, remainder;
string foo;
MAX = 10;
foo = Console.readln();
foo = String.trim(foo, "\n");
if(String.isNumber(foo))
{
MAX = String.toNumber(foo);
} else {
Console.println("Useage: primes.fe [Max Num]\n");
}
if(MAX < 1) { Console.println("Invalid Max Num\n"); }
i = 0;
for(cnt = 3; cnt <= MAX; cnt +=2)
{
test = Math.sqrt(cnt);
remainder=1;
for(i=3; i<= test; i+=2)
{
remainder = cnt%i;
if(! remainder) break;
}
if(remainder)
Console.println(cnt);
}