Advertisement
atishay11

DSA_Lab2_A

Feb 8th, 2021
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include<stdio.h>
  2. int fdivisors(int n)
  3. {
  4.     int i,j=0,counter=0,a[1000];
  5.     for(i=2;i<n;i++)
  6.     {
  7.         if((n%i)==0)
  8.         {
  9.             a[j] = i;
  10.             j++;
  11.             counter++;
  12.         }
  13.     }
  14.     if((counter==1)||(counter==0))
  15.     {
  16.         return(n);
  17.     }
  18.     else
  19.     {
  20.         return(fdivisors(a[counter])+fdivisors(a[counter-1]));
  21.          
  22.     }
  23.        
  24. }
  25. int main()
  26. {
  27.     int no,result;
  28.     scanf("%d", &no);
  29.     result = fdivisors(no);
  30.     printf(result);
  31.     return(0); 
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement