Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- bool p_n(int);
- int main(){
- int num;
- for(num=1;num<=1000;num++){
- if(p_n(num))
- printf("%d\n",num);
- }
- system("PAUSE");
- return 0;
- }
- bool p_n(int n){
- int c;
- int temp=0;
- for(c=1;c<n;c++){
- if(n%c==0)
- temp = temp+c;
- }
- if(n==temp)
- return true;
- else
- return false;
- }
Add Comment
Please, Sign In to add comment