Computer Science, asked by premsagar15016, 4 months ago

c program sum of factors of number 6 using recursion

Answers

Answered by keyboardavro
2

Answer:

Explanation:

// of a number using recursion  

 

#include <bits/stdc++.h>  

using namespace std;  

 

// Recursive function to  

// print factors of a number  

void factors(int n, int i)  

{  

   // Checking if the number is less than N  

   if (i <= n) {  

       if (n % i == 0) {  

           cout << i << " ";  

       }  

 

       // Calling the function recursively  

       // for the next number  

       factors(n, i + 1);  

   }  

}  

 

// Driver code  

int main()  

{  

   int N = 16;  

   factors(N, 1);  

}

Similar questions