Guest User

Untitled

a guest
Jul 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int sumfactors(int);
  5.  
  6. int
  7. main(int argc, char **argv) {
  8.     int n, sumfact, i;
  9.     int
  10.     sumfactors(int n) {
  11.     sumfact=0;
  12.     for (i=1; i<=n; i++){
  13.         if (n%i==0){
  14.         sumfact+=i;
  15.         }
  16.     }
  17.     return sumfact;
  18.     }
  19.    
  20.     printf("Enter number for its factors to be added: ");
  21.     scanf("%d", &n);
  22.     printf("The sum of the factors of %d is %f", n, sumfactors(n));
  23.    
  24.     return 0;
  25. }
Add Comment
Please, Sign In to add comment