Java code the list all the factors of a number

I was wondering if anyone could help me with this problem?

Two message boxes come up asking the user first to input a factor and then the next is to enter a multiple. I have to figure out if the first value is a factor of the second value. I know to use the modulus operator but I'm still confused. Can someone please give me some helpful hints?

Thanks

[372 byte] By [Limeblaira] at [2007-10-3 6:54:26]
# 1

the first number is a factor of the second. That means that the second number is an even multiple of the first. that means that the second number will have no remainder when divided by the first.

You know that the modulus function %, returns the remainder of an integer division. so you know that second mod first should equal zero if second is a multiple of first.

int second, first;

if ((second % first) == 0) {

// first is factor of second

} else {

// first is not factor of second

}

that is your algorithm. All the rest about message boxes and entering numbers and showing results is User Interface.

marlin314a at 2007-7-15 1:45:59 > top of Java-index,Other Topics,Algorithms...