Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Palindromic Number  RSS feed

 
Arjun Shastry
Ranch Hand
Posts: 1906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finding the word whether its Palindromic had been discussed in the past.How about numbers? and that without using String or character array?I wrote a program but its rather brut force.i.e. comparing quotient with remainder and reducing the number and repeating till middle one.
Any other better approach?
 
Marcel de Jong
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Capablanca,
how about reducing the original number with it reverse? This should always result in zero (0). If not, you don't have a palindrome.
Regards,
Marcel
 
Arjun Shastry
Ranch Hand
Posts: 1906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this will increase one additional step.bcos brut force,we are doing the same thing.
 
Nick George
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could always cheat...
String s=(new Integer(1881)).toString();
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!