Ok, I have a problem.

I'm trying to make a program that prints all the prime factors of a given number and the 29 numbers one less than it. These numbers iare 432731 -> 432702.

So here is my program:

public class evan5ccc

{

/* the method tests whether a number is prime*/

public static boolean Primes(int input)

{

for (int x=2; x < input; x++)

if (input % x == 0)

return false;

return true;

}

/*

computes the smallest prime factor of the input number,

returns that number divided by its smallest prime factor

*/

public static int factor (int input)

{

if (input == 1)

return input;

else

{

for (int x=2; x <= input; x++)

if (input % x == 0)

{

System.out.print(" " + x );

return (input / x);

}

}

return 0;

}

public static void main(String args[])

{

int number;// number to be decomposed

for (number=432731; number > 432701; number--)

System.out.println("Prime factors of " + number + ":");

while (number != 1)

{

number = factor(number);

}

}

}

And here is the output:

Prime factors of 123456760:

Prime factors of 123456761:

Prime factors of 123456762:

Prime factors of 123456763:

Prime factors of 123456764:

Prime factors of 123456765:

Prime factors of 123456766:

Prime factors of 123456767:

Prime factors of 123456768:

Prime factors of 123456769:

Prime factors of 123456770:

Prime factors of 123456771:

Prime factors of 123456772:

Prime factors of 123456773:

Prime factors of 123456774:

Prime factors of 123456775:

Prime factors of 123456776:

Prime factors of 123456777:

Prime factors of 123456778:

Prime factors of 123456779:

Prime factors of 123456780:

Prime factors of 123456781:

Prime factors of 123456782:

Prime factors of 123456783:

Prime factors of 123456784:

Prime factors of 123456785:

Prime factors of 123456786:

Prime factors of 123456787:

Prime factors of 123456788:

Prime factors of 123456789:

3 3 3607 3803

This is copied and pasted from the sample output, so the numbers are wrong, but it basically prints just the last number's prime factors, instead of all 30. Also, it prints it on the next line, because i used println, but if I use print then it all goes into a big mess.

The output is supposed to look like this:

Prime factors of 123456760: 2 2 2 5 7 271 1627

Prime factors of 123456761: 123456761

Prime factors of 123456762: 2 3 3 11 13 47963

Prime factors of 123456763: 4021 30703

Prime factors of 123456764: 2 2 617 50023

Prime factors of 123456765: 3 5 523 15737

Prime factors of 123456766: 2 1051 58733

Prime factors of 123456767: 7 17636681

Prime factors of 123456768: 2 2 2 2 2 2 2 2 3 160751

Prime factors of 123456769: 53 283 8231

Prime factors of 123456770: 2 5 29 425713

Prime factors of 123456771: 3 3 3 17 268969

Prime factors of 123456772: 2 2 30864193

Prime factors of 123456773: 11 83 135221

Prime factors of 123456774: 2 3 7 7 419921

Prime factors of 123456775: 5 5 13 19 19993

Prime factors of 123456776: 2 2 2 79 195343

Prime factors of 123456777: 3 5779 7121

Prime factors of 123456778: 2 23 1531 1753

Prime factors of 123456779: 109 173 6547

Prime factors of 123456780: 2 2 3 3 5 47 14593

Prime factors of 123456781: 7 41 149 2887

Prime factors of 123456782: 2 61728391

Prime factors of 123456783: 3 2797 14713

Prime factors of 123456784: 2 2 2 2 11 11 43 1483

Prime factors of 123456785: 5 24691357

Prime factors of 123456786: 2 3 20576131

Prime factors of 123456787: 31 31 128467

Prime factors of 123456788: 2 2 7 13 17 71 281

Prime factors of 123456789: 3 3 3607 3803

So how do I make all 30 prime factorizations happen? I've been staring at this code for some time now and I can't figure it out.

Can anybody help?