Java examples for Algorithm:Number
prompts the user for a positive integer and then displays that integers prime factors
import java.util.Scanner; public class PrimeFactors { public static void main(String[] args) { Scanner scan = new Scanner (System.in); double number; System.out.print("Enter number"); number=scan.nextInt();/*from w w w . j a v a 2s . c o m*/ int count= 2; while (count<= number){ if (number%count==0){ System.out.println(count); number=number/count; } else count= count+1; } } }