prime pal 1 Answer(s) 3 years and 9 months ago
Posted in : Java Beginners
View Answers
September 7, 2009 at 4:14 PM
Hi Friend,
1)Prime and Palindrome:
import java.util.*;
public class PrimeAndPalindrome { static final int MAXNUMBER=500; private int number; private ArrayList<Integer> list = new ArrayList<Integer>(); public PrimeAndPalindrome(int maxNum){ number=maxNum; } ArrayList<Integer> isPalindrome(){ for (int i=10; i<=number; i++){ Integer in=new Integer(i); String number=in.toString(); int index1=0; int index2=number.length()-1; char x=number.charAt(index1); char y=number.charAt(index2); while (index2-index1>=0){ if(x!=y) break; if (index2-index1==0 || index2-index1==1) list.add(i); index1++; index2--; x=number.charAt(index1); y=number.charAt(index2); } } return list; } static boolean isPrime(int number){ boolean isPrime=false; int i=(int) Math.ceil(Math.sqrt(number)); while (i>1){ if ((number!=i) && (number%i==0)){ isPrime=false; break; } else if (!isPrime) isPrime=true; --i; } return isPrime; } public static void main(String[] args) { ArrayList<Integer> palindromes=new ArrayList<Integer>(); PrimeAndPalindrome pp=new PrimeAndPalindrome(MAXNUMBER); palindromes=pp.isPalindrome(); Iterator<Integer> iter=palindromes.iterator(); while (iter.hasNext()){ int current=iter.next(); if (isPrime(current)) System.out.println(current); } } }
Related Pages:
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.
prime number prime number To check a number entered by user is prime
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 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 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 prime number to check wethere given number is prime or not?
 ... is Prime!");
}
else{
System.out.println("Number is not prime!");
}
}
}
Thanks
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 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
prime nos prime nos Instead of using break statement in finding the prime nos ,is there any other way ??
if it is there pls tell that also
import java.io.*;
class FindPrimeWithoutBreak
{
public static void main(String
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
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 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 <
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
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
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
Prime Numbers from range Prime Numbers from range how to find prime numbers in a given range which are palindromes??
Hi Friend,
Try the following code:
import java.util.*;
public class PrimeAndPalindrome {
static final int MAXNUMBER
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
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 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
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
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... 1 and themselves. For example, some of the
first prime numbers are 2, 3, 5, 7
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
Pick Prime Numbers from the ArrayList
Pick Prime Numbers from the ArrayList
Programmers mostly used 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.
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 AND EVEN AND ODD - Java Interview Questions PRIME AND EVEN AND ODD how to write prime numbers?i want source code... want source code? Hi Friend,
1)Following code displays the prime... args[]){
String primeNo = "";
int j=0;
System.out.println("Prime Numbers
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
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
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 BigInteger example
Java BigInteger example
BigInteger class provides us operations for modular arithmetic
(such as add, subtract) , prime generation , bit manipulation and many other
useful
PHP Beginners Guide, Free PHP Beginners Guide
This PHP Beginners Guide will help and educate all the programmers especially the beginners who want to learn PHP as a prime subject or as a supplement subject. PHP is primarily used for making dynamic web pages, and those who want
Tourist Places of Mizoram India
Tourist Places in Mizoram
Mizoram, a pleasing state for tourism is one of the prime tourist places of
northeast India. The state of Mizorzam is one among the seven sisters state of
India that houses rolling hills, deep valleys
answer it soon
answer it soon write a proggram to accept a number and check whether the sum of prime factors of a number is a prime number
Core Java
Core Java have to find the prime numbers which is less than the current prime numbers using loops
hi
logic for prime number Logic for prime number in Java. HTML Tutorials
GPS Tracking for Cars
GPS technology has proved to be a great measure to track your objects especially when they are moving objects, such as your car. GPS tracking for cars can help to reduce the security issues which is a prime concern of the car owners due
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
Multi-Threading - Java Beginners
Multi-Threading Consider a producer process prime-generator produces 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
java query
java query why do we divide the number by 2 in for loop in the prime number program
Java
or not the number is prime. Prime numbers are positive integers greater than 1 which can only be evenly divided by 1 and themselves (e.g. 7 is prime, because it can only be evenly divided by 1 and 7, but 9 is not prime because it can be evenly divided
java
java How to write coding in java for prime numbers??
Thanking you in advance