• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Palindrome Prime, comparing reversed number

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me just start off by saying hello all Im new here and hopefully someone might be able to guide me in my problem.

I have to find numbers & list numbers that are prime and also palindrome like :
2 3 5 7 11 101 131 151 181 191
313 353 373 383 727 757 787 797 919 929

I was able to find the prime numbers (up to 20 for now just to make sure im on track)
However, i think something may be wrong with my reverse method because it doesnt compare properly in my if statement for option1.
If you untoggle the reverse(562897498) it gives the number reversed so im not sure what is wrong.

Any help would be awesome!
Ahh sorry if the code is messy, I've been working on this for a few hours

 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Notice in your reverse method, you aren't doing anything to the input. You create a local variable y, but you don't use it. You just return x
 
Miguel Jr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Keith Lynn wrote:Notice in your reverse method, you aren't doing anything to the input. You create a local variable y, but you don't use it. You just return x



Just noticed that, I am just printing getting the same value back

Got it working now!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic