I had come over another issue with STL.
I am trying to write a program that takes a number 'n' (1 <= n <= 10.000) and prints the "decomposition into prime factors" (I know that the translation to English isn't good).
The program doesn't show any errors or warnings at compilation, but it looks like it gets stuck or goes into an infinite loop, as it doesn't show any message in the console window and neither does it modify the output file.
You have an infinite loop starting at line 25, and your OS is too stupid to notice and kill the program for you.
Either way though, you need to rethink how you are decomposing n into prime factors. Your output, for example, should be
32 × 51
since 3 × 3 × 5 = 45.
Using the map is smart. The way you are checking for primes and factors is confused. As you are figuring it out, remember that it is OK to modify n. Hint:
1 2 3 4 5 6 7 8 9 10 11 12
for every prime number p from 2 to (n / 2) AND while (n != 0)
{
if p evenly divides n
{
update the map with this simple code:
m[ p ] += 1;
update n:
n /= p;
}
}
write the output using lines 40 through 44 as you have it already
Firstly, I guess you'd be amazed to find out that my OS is the brand new Windows 8.
Thanks for the reply and for the explanation.
I think I will be able to work it out now.
EDIT: About the text... Yeah, sorry, the program is suppose to show the "decomposition into prime factors" of the n! (n factorial). So, in my example, 1 x 2 x 3 x ... x 45
EDIT 2: Found my issue... The line 35 should have been before line 34, so the program works now. Thanks again. ^^