I think u hav misunderstood my logic ..... I told " What comes to my mind is to get all PRIME FACTORS from 2 to SQRT(N) [Prime Sieve] , Here N is the Given Integer . "
So I wrote the code and let me know if there is any problem :- #include<cstdio> #include<iostream> #include<cmath> using namespace std; #define N 1000000 int prime[N+1],arr[N+1]={0}; int main() { int num,temp; for(int i=2;i<=sqrt(N);i++) for(int j=i*i;j<=N;j+=i) arr[j]=1; int c=0; for(int i=2;i<=N;i++) if(!arr[i]) {prime[c++]=i;} while(1) { scanf("%d",&num); int i=0; for(;prime[i]<=sqrt(num);i++) { temp=num; if(!(temp%prime[i])) while(!(temp%prime[i])) temp/=prime[i]; if(temp==1) { printf("Possible\n"); break; } } if(prime[i]>sqrt(num)) printf("Not Possible\n"); } getchar(); return 0; } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.