Hey guyz i'm a newbie in java and I would like to create a program to find all palindrome prime numbers between two integers supplied as input (start and end points are excluded). I've started but now i'm stuck... Can u help me???

import java.util.*;
class Question4{
    public static void primeNumber (int limit){


    Scanner user = new Scanner (System.in);

    int x;
    int y;
    int div=2;
    int count=0;

    System.out.println ("Enter the starting point N:");
      x = user.nextInt();
    System.out.println ("Enter the ending point M:");
      y = user.nextInt();
    while (count>x && count<y){
        for (i=0;i>x;i++)
    }
  }
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

You will never get inside the while loop because you set count=0 and you don't know what x or y will be. Since you are setting x to be you starting number try this:

int x;
int y;
int div=2;
int count=0;

System.out.println ("Enter the starting point N:");
x = user.nextInt();
System.out.println ("Enter the ending point M:");
y = user.nextInt();

[B]count=x+1;[/B]

while (count<y){
//your code here

//in the end:
count++;
}

or try this:

for (int i=x+1;i<y;i++) {

}

By the way what kind of algorithm will you use?

Then you have a bit of studying to do, because that is the heart of the homework assignment. If you need help with homework, you'll need to get a little further than this on your own.

This article has been dead for over six months. Start a new discussion instead.