Skip to content

Instantly share code, notes, and snippets.

@nsuan
Created April 28, 2009 08:12
Show Gist options
  • Save nsuan/103020 to your computer and use it in GitHub Desktop.
Save nsuan/103020 to your computer and use it in GitHub Desktop.
//#include "iostream.h"
#include "stdio.h"
void main() {
int i, n, x;
i = 2;
printf( "Input number: ");
scanf( "%d" , &n);
x = 0;
while( i <= n) {
x = n % i;
if ((x == 0) && (n == i)) {
printf("\n%d is prime.\n", n);
return;
}
if ((x == 0) && (n != i)) {
printf("\n%d is not prime. \n", n);
break;
}
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment