Hi everybody i have a little test and i need to ask something

So i have this code ("this is the correct form")

Code :

public static String buildPrimeNumbers(int num){
String sum="";int j=num;
for (int i=2;i<=(j/2);i++){
while (num%i==0) {sum+=i+" ";
num=num/i;}
}
return sum;}

and i have this one("this is what i did ,its look almost exectly like the first one exept i didnt install int j")

Code :

public static String buildPrimeNumbers(int num){
String sum="";
for (int i=2;i<=(num/2);i++){
while (num%i==0) {sum+=i+" ";
num=num/i;}
}
return sum;}

my question is my is my code doesn't give me the exact prime numbers as the correct one.

what is the matter between if i put (i<=(num/2)) or (i<=j/2) .while j==num?

Re: Hi everybody i have a little test and i need to ask something

The code in the loop changes the value of num. j is unchanged.

Re: Hi everybody i have a little test and i need to ask something

Re: Hi everybody i have a little test and i need to ask something

Quote:

i have a little test

Anyone under 4 feet!