Results 1 to 3 of 3
Thread: greatest prime factor
 07232010, 01:29 PM #1Member
 Join Date
 Jul 2010
 Posts
 6
 Rep Power
 0
 07232010, 04:23 PM #2
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,422
 Blog Entries
 7
 Rep Power
 29
 07232010, 08:28 PM #3Member
 Join Date
 Jul 2010
 Posts
 6
 Rep Power
 0
i have found all the prime factors. r u saying that the last prime factor will be the largest prime factor? my code is:
import java.util.Scanner;
public class GPF {
public static void main(String[] srgs) {
Scanner keyboard = new Scanner(System.in);
int num,prifac,count=0;
System.out.print("Enter a number: ");
num = keyboard.nextInt();
for(int i=1;i<num;i++){
if(num%i == 0){
for(prifac=2;prifac<i;prifac++){
if(i%prifac == 0){
count++;
}
}
if(count<=0){
System.out.print(i+"\t");
}
count =0;
}
}
}
}
wat shud i add to ensure that the last prime factor is the largest and shud be printed?
thnx
Similar Threads

Finding Largest Prime Factor
By perito in forum New To JavaReplies: 7Last Post: 11082010, 08:25 PM 
Returning the Greatest Prime Factor
By BJ1110 in forum New To JavaReplies: 15Last Post: 10232009, 10:06 PM 
Prime Number  System print all the prime numbers ...
By pinkdreammsss in forum New To JavaReplies: 20Last Post: 04262009, 01:50 AM 
find the greatest and lowest number in 2D array
By le_albina@hotmail.com in forum New To JavaReplies: 2Last Post: 03302009, 11:09 PM 
Prime numbers
By gapper in forum New To JavaReplies: 3Last Post: 02072008, 10:09 AM
Bookmarks