[ create a new paste ] login | about

Link: http://codepad.org/fAUmVkXG    [ raw code | fork ]

C++, pasted on Apr 27:
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	bool a[46342];
	for(int w=1;w<=46341;w++){
		a[w]=true;
	}
	a[0]=false;a[1]=false;
	for(int t=1;t<317;t++){
		if(a[t]){
			for(int q=2;q*t<=46341;q++){
				a[q*t]=false;
			}
		}
	}
	int b,x=0;
	while(scanf("%d",&b)!=EOF){
		for(int t=2;t<=46341;t++){
			if(t==b){
				break;
			}
			if(a[t]){
				if(0==b%t){
					x=1;
				}
			}	
			
		}
		if(x==1){
			printf("非質數\n");
		}
		if(x==0){
				printf("質數\n");
			}
		x=0;
	}
}


Output:
No errors or program output.


Create a new paste based on this one


Comments: