# how to find the nth prime number in java

priyarajan
how to find the nth prime number in java
1 Answer(s)      5 years and 6 months ago
Posted in : Java Beginners

strong texthow to find the nth prime number in java

November 18, 2011 at 4:01 PM

```class FindNthRrime{

public static void main(String a[]) {
find(7);
}
static void find(int n){
int i=0,count=2;
if(n==1)
{
System.out.println("1st prime =2");
return;
}
if(n==2)
{
System.out.println("2nd prime =3");
return;
}

while(true)
{
for(int j=2;j<=i/2;j++){
if(i%j==0)
break;
else if(j==i/2)
{
count++;
}
}
if(count==n)
{
System.out.println(n+"th prime ="+i);
break;
}
i++;
}
}
}
```

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... displayed a simple message and if the number is not a prime number we have find all
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
prime number - Java Beginners
prime number  i want to write a code in java that picks prime numbers from an existing list regardless how long the list is, it should then select non prime numbers when prime numbers are finished   Hi Friend, Try
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
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
Prime number program in java
Prime number program in java In this example you will learn how to write a program to generate and check  prime number  in java. As we know prime... a class with class name prime number, using switch case, in case first using two
prime number
prime number  write a java program for prime number
prime number
prime number  check prime number using if statement   Java Check Prime Number
prime number
prime number  check prime number using if statement   Java Check Prime Number
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... prime number. ADS4ThUnitADS Here is the code of the java Program to get prime
prime number
prime number  get one number and check the number prime or not using if statement   Java Check Prime Number
prime number question - Java Beginners
prime number question  For the question located here: http://www.roseindia.net/answers/viewanswers/5778.html How do you make it so that the user has to input the two numbers and it displays the prime numbers within the range
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
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
prime number
prime number  To check a number entered by user is prime
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
How can i read a file from nth line onwards in java
How can i read a file from nth line onwards in java  Hi, I need to read a file content from its nth line onwards till end. How can i implement it in java. Regards, Chinnu
Prime Number in Java
Prime Number in Java       This Java programming tutorial, we will be read how to get prime number.... If number is divided by any number that means it is not prime otherwise prime number
how to find largest number? - Java Interview Questions
how to find largest number?  this is my java coding: import...); } } i don't know how to add code to find the largest number.. please help...; yup yup.. i want to know how to find the greatest number that enter
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
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
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
how to display nth greatest salary - SQL
how to display nth greatest salary  how to display nth greatest salary
compute nth root - Java Beginners
compute nth root  write a program that computes the nth root of a number. given a real number X greater than 1 and less than -1 and given an integer Y, compute the nth root Z such that Z*Z*Z*Z*Z*Z*Z...(Y times)..Z*Z=X, or Z^y=X
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
how to find square and cube of five number
how to find square and cube of five number  how to find square and cube of five number   Hi Friend, Try the following code: <html> <script> document.writeln("Square of 5 numbers:<br><br>
prime numbers - Java Beginners
prime numbers  Write a java program to find the prime numbers between n and m
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
How do I find out the number of parameters passed into function9. ?
How do I find out the number of parameters passed into function9. ?  How do I find out the number of parameters passed into function9
How can we find the number of rows in a result set using PHP?
How can we find the number of rows in a result set using PHP?   How can we find the number of rows in a result set using PHP
how to find the roots of polynomial equation of 'n'th degree in java
how to find the roots of polynomial equation of 'n'th degree in java  i am new to java field and i wanted to find the roots of nth degree polynomial equation pls help me. thanks
Tutorials