Results 1 to 3 of 3
Thread: greatest prime factor
- 07-23-2010, 01:29 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 6
- Rep Power
- 0
- 07-23-2010, 04:23 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,410
- Blog Entries
- 7
- Rep Power
- 17
- 07-23-2010, 08:28 PM #3
Member
- 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: 11-08-2010, 08:25 PM -
Returning the Greatest Prime Factor
By BJ1110 in forum New To JavaReplies: 15Last Post: 10-23-2009, 10:06 PM -
Prime Number - System print all the prime numbers ...
By pinkdreammsss in forum New To JavaReplies: 20Last Post: 04-26-2009, 01:50 AM -
find the greatest and lowest number in 2D array
By le_albina@hotmail.com in forum New To JavaReplies: 2Last Post: 03-30-2009, 11:09 PM -
Prime numbers
By gapper in forum New To JavaReplies: 3Last Post: 02-07-2008, 10:09 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks