### Tanbin_Hasan's blog

By Tanbin_Hasan, history, 5 weeks ago,

https://www.geeksforgeeks.org/generating-all-divisors-of-a-number-using-its-prime-factorization/

Here , I got a answer for it . But I didn't understand the recursion process .

Could you please help me to do this iteratively ? Kindly convert it from recursive to iterative form . Need help from my programmer brothers . I'll be grateful to you all .

Thanks in advance .

• -17

 » 5 weeks ago, # |   0 Auto comment: topic has been updated by Tanbin_Hasan (previous revision, new revision, compare).
 » 5 weeks ago, # |   +17 int n; cin >> n; vector> primes; for( int p = 2; p * p <= n; p++ ){ if( n % p == 0 ){ int cnt = 0; while( n % p == 0 ) cnt++, n /= p; primes.push_back( { p, cnt } ); } } if( n > 1 ){ primes.push_back( { n, 1 } ); } vector d; d.push_back( 1 ); for( int i = 0; i < primes.size(); i++ ){ int size = d.size(); int p_pow = 1; for( int j = 0; j < primes[i].second; j++ ){ p_pow *= primes[i].first; for( int i = 0; i < size; i++ ){ d.push_back( d[i] * p_pow ); } } } for( int x: d ){ cout << x << " "; } cout << endl;
•  » » 5 weeks ago, # ^ |   0 Nazarbek_Baltabaev Take love brother