Last active
December 16, 2015 22:20
-
-
Save 0xAether/5506344 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
*To-do: | |
* - Use bitwise operations for everything | |
* - Add ability to output to a file | |
*/ | |
#include <stdio.h> | |
#include <stdbool.h> | |
#include <limits.h> | |
bool isPrime(unsigned long long num); | |
bool isPrime(unsigned long long num) { | |
unsigned long long c = (num >> 1); | |
for( c; c >= 2; c-- ) { | |
if ( num % c == 0 ) return false; | |
} | |
return true; | |
} | |
int main(void) { | |
unsigned long long c; | |
for ( c = 2; c <= ULLONG_MAX; c++ ) { | |
if ( isPrime(c) == true ) printf("%d\n", c); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment