Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to find the prime numbers in java

import java.util.*;
class Example{
	public static boolean isPrime(int num){
		for(int i=2; i<num; i++){
			if(num%i==0){
				return false; 
			}
		}
		return true;
	} 
	public static void main(String args[]){
		for (int i = 0; i < 1000; i++){
			if(isPrime(i)){
				System.out.println(i);	
			}
		}
	}
}
Source by beginnersbook.com #
 
PREVIOUS NEXT
Tagged: #find #prime #numbers #java
ADD COMMENT
Topic
Name
4+4 =