Comment

Zakir Sajib
first 100 prime numbers,
August 1, 2010 at 12:13 PM

int num = 2;
int i;
int nPrimeCount = 0;
int primeCount = 0;

do
{

for (i = 2; i <num; i++)
{

int n = num % i;

if (n == 0) {

nPrimeCount++;
// System.out.println(nPrimeCount + " " + "Non-Prime Number is: " + num);

num++;
break;

}

}

if (i == num) {

primeCount++;

System.out.println(primeCount + " " + "Prime number is: " + num);
num++;
}

}while (primeCount<100);

View All Comments | View Tutorial
Related Tutorial and Articles
Java Beginners

prime number - Java Beginners
prime number  this project is to determine if a phone number is a prime number. if the number is a prime number then print a message to the effect. if the number is not a prime number then print the prime factors of the number

Java Beginners

prime number - Java Beginners
prime number  i want to write a code in java that picks prime numbers... non prime numbers when prime numbers are finished   Hi Friend, Try...); System.out.println("Prime Numbers are: "); for(int i=0;i

Java Beginners

prime number question - Java Beginners
prime number question  For the question located here: http... has to input the two numbers and it displays the prime numbers within the range...; System.out.println("Prime Numbers between "+num1+" and "+num2

Java-Tutorials

Prime Number program in Java
Prime Number program in Java will print the prime numbers between 1 to any given number. Prime Number is a number that is not divisible by any number other... automatically prints Prime Number starting from 1 to 50. Example of Prime Number

Java Tips and Examples

Prime number program in java
Prime number program in java In this example you will learn how to write... a class with class name prime number, using switch case, in case first using two...; number<=limit; number++){ //print prime numbers only

Development process Questions

prime number
prime number  check prime number using if statement   Java Check Prime Number

Development process Questions

prime number
prime number  check prime number using if statement   Java Check Prime Number

Java Beginners

prime number
prime number  write a java program for prime number

Development process Questions

prime number
prime number  get one number and check the number prime or not using if statement   Java Check Prime Number

Java Beginners

prime number
prime number  HI!I want a java program that accepts a number from user and displays whether it is a prime number or not using BufferedReader

Java Beginners

prime number
prime number  To check a number entered by user is prime or not?   Java check prime number import java.util.*; class CheckPrimeNumber... is Prime!"); } else{ System.out.println("Number

General

Prime Number in Java
Prime Number in Java       This Java programming tutorial will be read how to get prime number. First of all we will define a class "Prime Number". Java I/O package

Java Tips and Examples

Prime Number in Java
Prime Number in Java       This Java programming tutorial, we will be read how to get prime number between 1 to given number. First of all we have to define a class "

Java-Tutorials

Prime Number in Java
Prime Number in Java In this Java tutorial , you will learn how to write a Java program to get prime numbers between 1 to the desired number. To start... the bytes. In this example of writing java program to get prime numbers, we

Java Tips and Examples

Find out the prime number
Find out the prime number      ... to find out whether a given number is prime or not. Here we have used the 'for loop' statement and given the required condition for a prime number. As we know

Java Beginners

prime number
prime number  could u pls help me out in finding whether a number is a prime number or not?   import java.util.*; class CheckPrimeNumber... is Prime!"); } else{ System.out.println("Number

Java Beginners

prime number
prime number  To check a number entered by user is prime

Java Interview Questions

prime number
prime number  to check wethere given number is prime or not?  ... is Prime!"); } else{ System.out.println("Number... { static boolean isPrime(int number){ boolean isPrime=false; int

Programming Tutorials

Find prime factors of non prime number
Find prime factors of non prime number In this section, you will learn how to find the prime factors of the non prime number. Here we have prompted the user to enter any number. If the number entered by the user is prime then we have

Java Beginners

Prime Numbers
Prime Numbers  Create a complete Java program that allows the user to enter a positive integer n, and which then creates and populates an int array with the first n prime numbers. Your program should then display the contents

Java Beginners

Palindromic Prime Numbers
Palindromic Prime Numbers  Write a program that finds the first palindromic prime number above 100,000. Include the value of this prime in a comment at the start of the code

Java Beginners

prime numbers - Java Beginners
prime numbers  Write a java program to find the prime numbers between n and m

Java Beginners

finding the prime numbers
about your problem. http://www.roseindia.net/java/beginners/Prime_number.shtml...finding the prime numbers  Hi, I am a beginner to java and I have problem with the code in finding the prime numbers, can someone tell me about

Java Beginners

Finding all palindrome prime numbers - Java Beginners
Finding all palindrome prime numbers  How do i write a program to Find all palindrome prime numbers between two integers supplied as input (start and end points are excluded

Java Beginners

prime numbers application
prime numbers application  how to add a comment indicating that the method will determine if a number is a prime number. In the next line add... a comment stating that 1 is not a valid prime number, on the next line add

Java Interview Questions

print 100 numbers using loops
print 100 numbers using loops  how to print from 1 to 100 using...{ public static void main(String[] args){ for(int i=1;i<=100;i...[] args){ for(int i=1;i<=100;i++){ System.out.println(i

General

Find Twin Primes Number using Java
Find Twin Primes Number using Java In this section, you will learn how find primes and twin primes from the first 100 natural numbers. For this, we have used the 'for loop' statement and set the required condition for a prime number

Java Beginners

multiply of 100 digits numbers
multiply of 100 digits numbers  multiplying 100 digits numbers to eachother

Java Beginners

Sum of first n numbers
Sum of first n numbers  i want a simple java program which will show the sum of first n numbers....   import java.util.*; public class...; } System.out.println("Sum of Numbers from 1 to "+n+" : "+sum

Java Beginners

numbers - Java Beginners
the odd number integers from 1 to 100, separated by a comma to the end of the file...numbers  Write a program to create a file named "numbers.dat". Then create an algorithm that adds all even numbered integers from 1 to 100, separated

Java Beginners

prime pal - Java Beginners
prime pal  1) WAP to print all prime-palindrome number range between 1-500 2) WAP to print all prime-Fibonacci number range between 1-500   Hi Friend, 1)Prime and Palindrome: import java.util.

General

Find Numbers which are palindrome and prime
Find Numbers which are palindrome and prime In this section, you will learn how to find the numbers from 1 to 500 which are palindrome and prime. To compute.... The Iterator class iterates the ArrayList and check whether number is prime

IDE Questions

Prime Numbers - IDE Questions
Prime Numbers  Create a program that calculates the prime numbers from any inputted start and end range of values (e.g. 5 and 28) and print the prime... = 0; System.out.println("Prime Numbers are:" ); for (int i = 1; i <

Java Beginners

Prime Numbers from range
Prime Numbers from range  how to find prime numbers in a given range...=200; private int number; private ArrayList<Integer> list = new ArrayList<Integer>(); public PrimeAndPalindrome(int maxNum){ number=maxNum

Java Code Examples

Java find prime numbers without using break statement
Java find prime numbers without using break statement In this tutorial, you will learn how to find the prime numbers without using break statement. You all are aware of Prime Numbers, these are the numbers which are either divided

Java Beginners

To find first two maximum numbers in an array
To find first two maximum numbers in an array  Java program to find first two maximum numbers in an array,using single loop without sorting array

General

Prime And Fibonacci Number Finder
Prime And Fibonacci Number Finder In this section, you will learn how to find the prime numbers which are generated in the fibonacci series. To compute... number is prime or not? If it is prime Number, the number will get displayed

Java Beginners

adding two numbers - Java Beginners
InputStreamReader(System.in)); System.out.println("Enter first no.:"); x[1...("Enter first no.:"); x[0]=Integer.parseInt(in.readLine()); System.out.println... information : http://www.roseindia.net/java/ Thanks

Java Beginners

Generate random numbers from 1 to 100
Generate random numbers from 1 to 100  1)A class Called: RandomNumberGenerator that generate random numbers from 1 to 100 2)A class Test that tests the hierarchy in A) especially the getArea() and getVolume() methods. Use

Java Beginners

generating random numbers - Java Beginners
of the known prices (except for the first 5, which don't have enough predecessors). We

IDE Questions

prime palendrome
prime palendrome  Hi I want to write a program that ask a user to input a number, the program then list all the prime number that are palindrome below the number entered. Thks

IDE Questions

prime palindrome
prime palindrome  Hi I want to write a program in pascal that ask a user to input a number, the program then list all the prime number that are palindrome below the number entered. thks

Java Beginners

java - Java Beginners
java  write a program in java to print first 10 prime number?  ... static void main(String args[] ){ int prime = 2; int count = 0; while(count < 10) { int k=0; for(int i = 2; i < prime ; i++){ if (prime%i == 0){ k=1

Java Beginners

prime numbers randomly that are displayed by a consumer process called prime-sorter . prime-sorter will display the prime number if it is greater than the previously displayed number. You have to write a multithreaded Java program

Java Beginners

random numbers - Java Beginners
random numbers  write a program to accept 50 numbers and display 5 numbers randomly  Hi Friend, Try the following code: import...); System.out.println("Enter 10 numbers: "); for(int i=0;i<10;i

Java Beginners

recursion numbers - Java Beginners
recursion numbers  I need to use recursion to test all values from 0 to 20 and see if they are contain in a 1-D array with values: 2,4,6,8,10,12,14,16,18,20. The results of all numbers from 0-20 will be printed

Java Beginners

random numbers - Java Beginners
to display the random numbers, but not twice or more. I mean i need a number to be display once. This code allows some numbers to be displayed more than once. Hi... Scanner(System.in); System.out.println("Enter 10 numbers: "); for(int i=0;i<10;i

Java Beginners

Perfect Numbers - Java Beginners
Perfect Numbers  The number 6 is said to be a perfect number because... + 2 + 3 Write a java program that finds and prints the three smallest perfect numbers. Use methods   Hi Friend, Try the following code: public

IDE Questions

prime palindrome
prime palindrome  Hi I want to write a program that ask a user to input a number, the program then list all the prime numbers that are palindrome below the number entered. In pascal language Thanks

Java Interview Questions

PRIME AND EVEN AND ODD - Java Interview Questions
PRIME AND EVEN AND ODD  how to write prime numbers?i want source code? how to write even numbers? i want source code? how to write odd numbers ?i... args[]){ String primeNo = ""; int j=0; System.out.println("Prime Numbers

Programming Tutorials

Pick Prime Numbers from the ArrayList
Pick Prime Numbers from the ArrayList Programmers mostly used ArrayList... and non prime numbers separately. Here is the code: import java.util....(array); System.out.println("Prime Numbers are: "); for (int i = 0; i <

Java Beginners

prime nos
[] args) { for (int number = 2; number <= 100; number++) { int maxFactor = (int)Math.sqrt(number); boolean isPrime = true; int...prime nos  Instead of using break statement in finding the prime nos

Java Beginners

Add two big numbers - Java Beginners
Add two big numbers - Java Beginners  Hi, I am beginner in Java and leaned basic concepts of Java. Now I am trying to find example code for adding big numbers in Java. I need basic Java Beginners example. It should easy

JSP Servlet Questions

odd numbers with loop
odd numbers with loop  get the odd numbers till 100 with for,while loop   Java find odd numbers: class OddNumbers { public static void main(String[] args) { for(int i=1;i<=100;i

Java Beginners

java programs - Java Beginners
java programs  Actually i am searching for the source code ,algorithm and flow chart for prime number ...can u suggest me where can i find it??? ...(); String primeNo = ""; int counter = 0; System.out.println("Prime Numbers between

Java Beginners

To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array

Java Beginners

To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array

Java Beginners

java code and logic - Java Beginners
java code and logic  Q1: PRINT FIRST 100 PRIME NUMBERS? Q2...; System.out.println("Prime Numbers are:" ); for (int i = 1; i < 100; i... T S  Hi Friend, 1)Prime Numbers class PrimeNumbers

Java Beginners

My first Java Program
My first Java Program  I have been caught with a practical exam to do... may not be less that 100 characters, else, you must ask the user to enter the sentence again of 100 characters. Take the user input break it up into different

Java Beginners

jav beginners - Java Beginners
the prime and twin prim numbers thanks  Hi Friend, Try... =i; } } System.out.println("Prime Numbers are: "+primeNo); } } Thanks...("Twin Primes are:" ); for (int i = 1; i < 100; i++){ for ( j = 2; j <

General

Calculate sum of even and odd numbers in Java
Calculate sum of even and odd numbers In this section, you will learn how to read the file that contains even and odd numbers and calculate their sum separately. To do this, first of all, we have found all the even and odd numbers from 1

Java Beginners

Printing numbers in pyramid format - Java Beginners
Printing numbers in pyramid format  Q) Can you please tel me the code to print the numbers in the following format: 1 2 3 4 5 6 7 8 9 10   Hi Friend, Try

Java Beginners

() { String num1; String num2; // read first number from the keyboard num1 = JOptionPane.showInputDialog("Enter a First number"); // read seond...Applet for add two numbers  what is the java applet code for add two

Java Beginners

java - Java Beginners
java  Q 1- write a program in java to generate Armstrong numbers up to a specific limit? Q2- write a program in java to check a given number for Fibonacci term? Q3- write a program in java to generate prime number up

General

Ordinal Numbers Series Program in Java
Ordinal Numbers Series Program in Java An ordinal number shows a relative... of the specified number by dividing it with 10 and 100. After that we have subtracted both... are going to display first 10 ordinal numbers. Here is the code: public

Java Beginners

java - Java Beginners
java  i want the program for // show if the given number is prime... = input.nextInt(); if (isPrime(num)) { System.out.println("Number is Prime"); } else{ System.out.println("Number is not Prime

Java Beginners

simple code - Java Beginners
simple code  to input a number and check wether it is prime...(bf.readLine()); System.out.println("Prime number: "); for (i=1; i < num; i... = Integer.parseInt(buff.readLine()); System.out.println("Prime number

Java Beginners

Java - Java Beginners
Java prime number program  How to show the prime number in Java? Can...; if (AePrimeExample.checkPrime(mersenne)) { System.out.print("Found Mersenne prime: "...://www.roseindia.net/java

Java Interview Questions

i dont no how to solve it pls
i dont no how to solve it pls   Calculate and display the sum of all prime number from 1 to 100 covert in java system codes

Java Tips and Examples

Write a program to list all even numbers between two numbers
Java Even Numbers - Even Numbers Example in Java: Here you will learn to write a program for listing out all the even numbers between two numbers. For this first create a class named

Java Beginners

automorphic numbers
automorphic numbers  how to find automorphic number in java   Hi Friend, Pleas visit the following link: Automorphic numbers Thanks

Java Beginners

how to add to numbers in java
how to add to numbers in java  how to add to numbers in java

Java Beginners

Program to display palindrome numbers between some range
Program to display palindrome numbers between some range  Hi!I want a java program to display palindrome numbers between 100 to 1000.can you please...(){ for (int i=100; i<=1000; i++){ Integer in=new Integer(i

General

Calculate the Sum of three Numbers
how to calculate three integer number . First of all define class name "... Calculate the Sum of Three Numbers       This is simple java programming tutorial

JavaScript Questions

defining numbers in Java Script
defining numbers in Java Script  Explain about defining numbers in Java Script

Java Beginners

Java - Java Beginners
Java    Write a multi-threaded Java program to print all numbers below 100,000 that are both prime and fibonacci number (some examples are 2, 3, 5, 13, etc.). Design a thread that generates prime numbers below 100,000 and writes

Java Tips and Examples

Comparing Two Numbers
Comparing Two Numbers       This is a very simple example of Java that teaches you the method of comparing two numbers and finding out the greater one. First of all, name a class

Core Java

Swapping of two numbers in java
Swapping of two numbers in java In this example we are going to describe swapping of two numbers in java  without using the third number in java. We... to number are swapped:- First we take two variable "a" and "b". initially

Java Beginners

java - Java Beginners
java  Write a multi-threaded Java program to print all numbers below 100,000 that are both prime and fibonacci number (some examples are 2, 3, 5, 13, etc.). Design a thread that generates prime numbers below 100,000 and writes

Java Beginners

java query
java query  why do we divide the number by 2 in for loop in the prime number program

Java Beginners

java program - Java Beginners
java program  Please send me a code to generate random numbers between 1 to 100 without repetition.... Thanks in advance...  Hi Friend... generateRandomNumber(int[] arr) { final int count = 100; Random random = new Random

Java Beginners

File - Java Beginners
number integers from 1 to 100, separated by a comma to the end of the file. Reopen... been displayed append the odd number integers from 1 to 100, separated by a comma... The first line above is after you add the even numbers to the file and print them

Java Beginners

JAVA - Java Beginners
a multi-threaded Java program to print all numbers below 100,000 that are both prime and fibonacci number (some examples are 2, 3, 5, 13, etc.). Design a thread that generates prime numbers below 100,000 and writes them into a pipe.Design

Java Beginners

JAVA - Java Beginners
a multi-threaded Java program to print all numbers below 100,000 that are both prime and fibonacci number (some examples are 2, 3, 5, 13, etc.). Design a thread that generates prime numbers below 100,000 and writes them into a pipe.Design

Java Beginners

Error in a code. - Java Beginners
and the output text area. A user is asked to type in a number. The first button when pressed should tell the user if that number is prime or not. When the second button is pressed the program has to calculate the prime factors of the given number. I

General

Swapping of two numbers
swap the numbers. To swap two numbers first we have to declare a class Swapping... Swapping of two numbers       This Java programming tutorial will teach you the methods for writing

Java Tips and Examples

Beginners Java Tutorial
Prime Number in Java This Java programming tutorial, we will be read how to get prime number between 1 to given number. First of all we have... Beginners Java Tutorial

General

First Step towards JDBC!
; MM MySQL JDBC DRIVERS - 100% pure java driver for MySQL... First Step towards JDBC      ... the databases. For the shake of simplicity, in very first example Access database

Java-Tutorials

Java examples for beginners
of examples. Java examples for beginners: Comparing Two Numbers The tutorial provide... of comparing two numbers and finding out greater one. First of all, you...In this tutorial, you will be briefed about the word of Java examples, which

HTML Questions

hi
logic for prime number  Logic for prime number in Java.   HTML Tutorials

Java Beginners

Another Question - Java Beginners
and the output text area. A user is asked to type in a number. The first button when pressed should tell the user if that number is prime or not. When the second button is pressed the program has to calculate the prime factors of the given number. I

Java Beginners

Java - Java Beginners
; } } System.out.println("Nr of prime numbers found...Java   plz give the code in JAVA language of the following programs..."); System.out.println(s+"444444"); } }   for your first question

Java Beginners

numbers divisible by 5 and 6
numbers divisible by 5 and 6  Find the first ten numbers which are greater than Long.MAX_VALUE divisible by 5 and 6

Java Beginners

Java Program - Java Beginners
Java Program  Write a program that prints prime numbers between 1 to n. Number n should be acepted as command line input.  Hi Friend... = ""; int counter = 0; System.out.println("Prime Numbers between 1 to "+num

Java Beginners

Generating random numbers in a range with Java
Generating random numbers in a range with Java  Generating random numbers in a range with Java

Java Interview Questions

Java program - convert words into numbers?
Java program - convert words into numbers?   convert words into numbers?   had no answer sir

Java Beginners

permutstion of numbers in java
permutstion of numbers in java  Is it possible to enter the number in a char so that permutation of a number can be acheived which...() { System.out.println("Enter the number of processors

Java Beginners

Java Pyramid of Numbers
Java Pyramid of Numbers  Hi, I want to know how the code to print the pyramid below works. It uses nested for loops. Pyramid: 1 2 1 2

Java Beginners

java programs - Java Beginners
java programs  1) write a program to print prime numbers? 2) write a program to print factorial of given number? 3)Please provide complete material...; Hi Friend, 1)Prime Numbers: import java.util.*; class PrimeNumbers

Java Beginners

Writing a GUI program - Java Beginners
is asked to type in a number. The first button when pressed should tell the user if that number is prime or not. When the second button is pressed the program has to calculate the prime factors of the given number. I figure out the whole