Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
10-08-2007, 02:04 AM #1
- Join Date
- Oct 2007
- Thanked 0 Times in 0 Posts
[C/C++] Output repeating numbers as n^b
I am trying to take my output for a prime number say for example for the number 135 I get 3 3 3 5 and I would like to output it as 3^3 5. Another example would be 612 which I would want to output as 2^2 3^2 17.
I am just looking for a pointer in the right direction. I want to code this myself.
10-09-2007, 03:03 AM #2
It's a bit difficult to get you started on this problem without also getting you finished, as the solution is very short. But, to be vague:
Handle one factor at a time, beginning by taking out as many 2s from the input number as you can and then working up with the remainder.
Make use of modulus (% operator) to test whether one number is a factor of another