FaltuTech.Club : Fane of Advanced Logical Thriving Utopian Technical Club

Prime Number Finder in Java Unoptimized and Optimized

Unoptimized



import java.io.*;
class PrimeUnoptimized{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
		
		System.out.print("Up to which number you want to print PN : ");
		int max = Integer.parseInt(br.readLine());
		
		// now calculate and print the numbers
		int track = 0;

		for(int i=1; i

Half Optimized



import java.io.*;
class PrimeOptimizedHalf{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
		
		System.out.print("Up to which number you want to print PN : ");
		int max = Integer.parseInt(br.readLine());
		
		// now calculate and print the numbers
		int track = 0;

		for(int i=1; i

Optimized



import java.io.*;
class PrimeOptimized{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
		
		System.out.print("Up to which number you want to print PN : ");
		int max = Integer.parseInt(br.readLine());
		
		// now calculate and print the numbers
		int track = 0;

		for(int i=1; i