Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Java Problem

  1. Nov 5, 2004 #1


    User Avatar

    Ok, I posted this in the software forum a this afternoon, but I guess all the java gurus are on vacation. So I thought I'd post it here. This is my problem:

    Ok, I have a new problem.

    This time 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:

    And here is the output:

    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:

    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.

    I know the for loop is screwed up because it isn't executing the whole statement and I know the contents of the while loop are screwed because I have two variables called the same name.

    Can somebody help me here? How do I go about fixing it?
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted