Skip to content

Instantly share code, notes, and snippets.

@0xAether
Last active December 16, 2015 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xAether/5506344 to your computer and use it in GitHub Desktop.
Save 0xAether/5506344 to your computer and use it in GitHub Desktop.
/*
*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