I have a c programming task that need a result as below: 99=11*3*3 100=5*5*2*2 101=101 102=17*3*2 If someone know how to do this programming, please share with me. Thank you.
it is simple just make factors
but how to make the larger prime factor appear first followed by the smaller one?
logic part looks like this.. for(i=2;i<=n;i++) { if(n%i==0) { printf("%d*",i); } }
but the result will be a smaller prime number to appear first, is'nt it? for example n=10, the result i want is 10=5*2 do you have any idea?
ther's a prob with that peudo code............it may not list all the prime facotors.......... say 8.....it wud give smthin like 2*4
i suggest u use recursion....
cin>>n; for(i=2;i<(n/2);i++) if(n%i==0) {a=n/i; cout<<i<<"*"<<a;
Join our real-time social learning platform and learn together with your friends!