Skip to content

Instantly share code, notes, and snippets.

@HallM
Last active January 25, 2016 23:39
Show Gist options
  • Save HallM/a19a0bc5aecdd1134ba0 to your computer and use it in GitHub Desktop.
Save HallM/a19a0bc5aecdd1134ba0 to your computer and use it in GitHub Desktop.
N primes in 98 bytes of C code
// trivial division
h,i=2;g(j){return j*j>i||i%j++&&g(j);}main(){scanf("%i",&h);for(;h;i++)g(2)&&printf("%i ",i,--h);}
// Wilson's Theory
h,i;m(n){return n?n*m(n-1)%i:1;}main(){scanf("%i",&h);for(;h;)m(i++)+1-i||printf("%i ",i,--h);}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment