prime pal

prime pal

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 Tutorials/Questions & Answers:
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.
ModuleNotFoundError: No module named 'pal'
ModuleNotFoundError: No module named 'pal'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pal' How to remove the ModuleNotFoundError: No module named 'pal' error
Advertisements
Version of com.lyncode>pal dependency
List of Version of com.lyncode>pal dependency
ModuleNotFoundError: No module named 'pal-tsne'
ModuleNotFoundError: No module named 'pal-tsne'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pal-tsne' How to remove the ModuleNotFoundError: No module named 'pal-tsne
ModuleNotFoundError: No module named 'philip-pal'
ModuleNotFoundError: No module named 'philip-pal'  Hi, My Python... 'philip-pal' How to remove the ModuleNotFoundError: No module named 'philip-pal' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'py-pal'
ModuleNotFoundError: No module named 'py-pal'  Hi, My Python...-pal' How to remove the ModuleNotFoundError: No module named 'py-pal'... to install padas library. You can install py-pal python with following command
ModuleNotFoundError: No module named 'riot-pal'
ModuleNotFoundError: No module named 'riot-pal'  Hi, My Python... 'riot-pal' How to remove the ModuleNotFoundError: No module named 'riot-pal... to install padas library. You can install riot-pal python with following
ModuleNotFoundError: No module named 'bph-pal'
ModuleNotFoundError: No module named 'bph-pal'  Hi, My Python...-pal' How to remove the ModuleNotFoundError: No module named 'bph-pal... to install padas library. You can install bph-pal python with following command
ModuleNotFoundError: No module named 'color-pal'
ModuleNotFoundError: No module named 'color-pal'  Hi, My Python... 'color-pal' How to remove the ModuleNotFoundError: No module named 'color-pal' error? Thanks   Hi, In your python environment you
prime number
prime number  To check a number entered by user is prime
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
Maven Dependency pal >> 1.0.5
You should include the dependency code given in this page to add Maven Dependency of com.lyncode >> pal version1.0.5 in your project
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
Maven Repository/Dependency: com.lyncode | pal
Maven Repository/Dependency of Group ID com.lyncode and Artifact ID pal. Latest version of com.lyncode:pal dependencies. # Version Release Date You can read more at: Maven
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 numbers - Java Beginners
prime numbers  Write a java program to find the prime numbers between n and m
Pay Pal
ModuleNotFoundError: No module named 'prime'
ModuleNotFoundError: No module named 'prime'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'prime' How to remove the ModuleNotFoundError: No module named 'prime'
ModuleNotFoundError: No module named 'prime'
ModuleNotFoundError: No module named 'prime'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'prime' How to remove the ModuleNotFoundError: No module named 'prime'
ModuleNotFoundError: No module named 'is-prime'
ModuleNotFoundError: No module named 'is-prime'  Hi, My Python... 'is-prime' How to remove the ModuleNotFoundError: No module named 'is-prime... to install padas library. You can install is-prime python with following
finding the prime numbers
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... number is prime or not, follow the link and it will provide you in depth knowledge
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 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
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
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
Version of com.real-comp>prime dependency
List of Version of com.real-comp>prime dependency
ModuleNotFoundError: No module named 'autoreload_prime'
ModuleNotFoundError: No module named 'autoreload_prime'  Hi, My... named 'autoreload_prime' How to remove the ModuleNotFoundError: No module named 'autoreload_prime' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'Divmod-Prime'
ModuleNotFoundError: No module named 'Divmod-Prime'  Hi, My Python... 'Divmod-Prime' How to remove the ModuleNotFoundError: No module named 'Divmod-Prime' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Divmod-Prime'
ModuleNotFoundError: No module named 'Divmod-Prime'  Hi, My Python... 'Divmod-Prime' How to remove the ModuleNotFoundError: No module named 'Divmod-Prime' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'medgen-prime'
ModuleNotFoundError: No module named 'medgen-prime'  Hi, My Python... 'medgen-prime' How to remove the ModuleNotFoundError: No module named 'medgen-prime' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'mine-prime'
ModuleNotFoundError: No module named 'mine-prime'  Hi, My Python... 'mine-prime' How to remove the ModuleNotFoundError: No module named 'mine-prime' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'mine-prime'
ModuleNotFoundError: No module named 'mine-prime'  Hi, My Python... 'mine-prime' How to remove the ModuleNotFoundError: No module named 'mine-prime' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'prime_algorithms'
ModuleNotFoundError: No module named 'prime_algorithms'  Hi, My... named 'prime_algorithms' How to remove the ModuleNotFoundError: No module named 'prime_algorithms' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'prime_factors'
ModuleNotFoundError: No module named 'prime_factors'  Hi, My... 'prime_factors' How to remove the ModuleNotFoundError: No module named 'prime_factors' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'prime_factors_95'
ModuleNotFoundError: No module named 'prime_factors_95'  Hi, My... named 'prime_factors_95' How to remove the ModuleNotFoundError: No module named 'prime_factors_95' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'Prime_Numbers'
ModuleNotFoundError: No module named 'Prime_Numbers'  Hi, My... 'Prime_Numbers' How to remove the ModuleNotFoundError: No module named 'Prime_Numbers' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'prime_algorithms'
ModuleNotFoundError: No module named 'prime_algorithms'  Hi, My... named 'prime_algorithms' How to remove the ModuleNotFoundError: No module named 'prime_algorithms' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'prime_factors'
ModuleNotFoundError: No module named 'prime_factors'  Hi, My... 'prime_factors' How to remove the ModuleNotFoundError: No module named 'prime_factors' error? Thanks   Hi, In your python

Ads