Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Palindrome Prime, comparing reversed number  RSS feed

 
Miguel Jr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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

 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!