Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5. int x;
  6. int suma=0;
  7. int main(int argc, char *argv[]) {
  8. system("cls");
  9. printf("%s","Podaj liczbe ktora chcesz sprawdzic czy jest ona doskonala \n");
  10. scanf("%i",&x);
  11.  
  12.  
  13. for(int i=1;i<=x/2;i++){
  14. if(x%i==0){
  15. suma=suma + i;
  16. }
  17.  
  18.  
  19. }
  20. if(suma==x){
  21. printf("%s","Podana liczba jest doskonala \n");
  22. }
  23.  
  24. printf("%i",suma);
  25.  
  26. system("pause");
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement