Home Answers Viewqa Java-Beginners how to find the nth prime number in java

 
 


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

strong texthow to find the nth prime number in java

View Answers

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++;
        }
    }
    }









Related Pages:
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
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
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
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
prime number  get one number and check the number prime or not using if statement   Java Check Prime Number
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
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
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 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 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
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
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
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
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
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
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 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
Pick Prime Numbers from the ArrayList
integer values in the arraylist and from the arraylist we have to find the prime and non prime numbers separately. Here is the code: import java.util....Pick Prime Numbers from the ArrayList Programmers mostly used ArrayList
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
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
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
prime numbers - Java Beginners
prime numbers  Write a java program to find the prime numbers between n and m
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
Find Twin Primes Number using Java
Find Twin Primes Number using Java In this section, you will learn how find... the 'for loop' statement and set the required condition for a prime number... by 1 and the number itself. Here we are going to find twin primes. Twin Primes
Primary number
Primary number  write a program to find the 100th or nth primary number?   import java.util.*; class PrimeNumber{ public static void...); System.out.print("Enter N:"); int n=input.nextInt(); find(n
Primary number
Primary number  write a program to find the 100th or nth primary number?   import java.util.*; class PrimeNumber{ public static void...); System.out.print("Enter N:"); int n=input.nextInt(); find(n
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.
how to display nth greatest salary - SQL
how to display nth greatest salary  how to display nth greatest salary
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
Read file from the Nth line
Read file from the Nth line Java provides several classes and methods to manipulate file. A file reading, is a common operation. Usually a file is to be read... Number: "); int no = input.nextInt(); try { LineNumberReader ln = new
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
Programming: Prime Numbers - Dialog
Java NotesProgramming: Prime Numbers - Dialog Name... the user, and displays a message about whether or not it's a prime number. Prime... to tell if a number is prime or not. Hint. The easiest way to decide if n is prime
find the largest number enter by user - Java Interview Questions
find the largest number enter by user  sorry for not stating clearly my question. i want to know how to find the largest number enter by user. thanks. this is my java coding: import java.util.Scanner; import java.io.
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 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
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
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
prime nos
prime nos  Instead of using break statement in finding the prime nos...[] args) { for (int number = 2; number <= 100; number++) { int maxFactor = (int)Math.sqrt(number); boolean isPrime = true; int
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
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 want source code?  Hi Friend, 1)Following code displays the prime
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
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
find factorial of any number using recursion
find factorial of any number using recursion  error in 14 line ; expected int rec( int a) ^ how to resolve this.please correct the code. import...)); System.out.println(?enter number?); int x=Integer.parseInt(br.readLine()); int result
Find Second Largest Number from an Array
Find Second Largest Number from an Array This section illustrates you how to find the second largest number from an array. For this purpose, we have allowed... among them. Pulls the largest number out from the array and again check
Java Find Median
Java Find Median In this tutorial, you will learn how to find the median of numbers. There is no built in method to find the median of a list of numbers in the Java framework. But you can create your own method when you need to find
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
find largest value
Java Find Largest Number import java.util.*; class FindLargest...find largest value  (Assignment 1 - LargestValue)The process... in computer applications. Write a Java application (LargestValue.java

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.