This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to store a reversed number as a new integer  RSS feed

 
Biran Quach
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pretty much what the title says, this is what i have so far. But i have no idea how to store it as an new integer


 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, you do realize you have a recursive implementation, but you do not have a halting condition--it will recurs forever.

Staying in the same algorithm you have already developed:

make an instance variable, initialize it to zero. multiply it by 10, then add your modulus of you number to it each time though.
 
Biran Quach
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks! i finsihed it

 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Reversed" numbers only have meaning if they are represented as text, not as integers. For example, what is the reverse of 2000? How about 200? 20? 2?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!