Guest User

Untitled

a guest
Jun 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. bool p_n(int);
  4.  
  5. int main(){
  6. int num;
  7.  
  8. for(num=1;num<=1000;num++){
  9. if(p_n(num))
  10. printf("%d\n",num);
  11. }
  12. system("PAUSE");
  13.  
  14. return 0;
  15. }
  16.  
  17. bool p_n(int n){
  18. int c;
  19. int temp=0;
  20. for(c=1;c<n;c++){
  21. if(n%c==0)
  22. temp = temp+c;
  23. }
  24. if(n==temp)
  25. return true;
  26. else
  27. return false;
  28. }
Add Comment
Please, Sign In to add comment