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.
 
 
 
 
 
 

26 lines
448 B

#!/usr/bin/env nickle
# nickle version of a prime number finder
# haplo@mindstab.net
if (dim(argv) <= 1)
{
printf("Usage: primes.5c [Max]\n");
exit(1);
}
int max = atoi(argv[1]);
for ( int number = 3; number <= max; number += 2)
{
low_max = sqrt(number);
isPrime = true;
for ( int factor = 3; factor <= low_max; factor += 2)
{
if ( number % factor == 0)
{
isPrime = false;
break;
}
}
if (isPrime) printf("%d\n", number);
}