Skip to content

Instantly share code, notes, and snippets.

@paranoidxc
Created May 15, 2014 08:50
Show Gist options
  • Save paranoidxc/37e27c5264120fa9b8db to your computer and use it in GitHub Desktop.
Save paranoidxc/37e27c5264120fa9b8db to your computer and use it in GitHub Desktop.
#define N 32
#include <iostream>
//#include <stdio.h>
//using namespace std;
main() {
int i, j, a[N];
for ( i = 2; i < N; i++ ) {
a[i] = 1;
}
for ( i = 2; i < N; i++ ) {
if ( a[i] ) {
for( j = i; i*j < N; j++ ) {
a[i*j] = 0;
}
}
}
for ( i = 2; i < N; i++ ) {
if( a[i] ) {
printf( "%4d", i );
}
}
printf("\n");
system("pause");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment