Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int sumfactors(int);
- int
- main(int argc, char **argv) {
- int n, sumfact, i;
- int
- sumfactors(int n) {
- sumfact=0;
- for (i=1; i<=n; i++){
- if (n%i==0){
- sumfact+=i;
- }
- }
- return sumfact;
- }
- printf("Enter number for its factors to be added: ");
- scanf("%d", &n);
- printf("The sum of the factors of %d is %f", n, sumfactors(n));
- return 0;
- }
Add Comment
Please, Sign In to add comment