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

strange question using % and /  RSS feed

 
Jesse Crockett
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this isn't really about code, but I'm supposed to take a five digit number, and using only the modulus and division operators, extract the leftmost digit, then just a vaguely "turn the five digit number into four digits" and repeat the process. I'm not sure if the initial value is supposed to stay the same. Anyhow, I'm at a loss and need some help.
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go back to the definition of / and %. It is hard to to give hints without giving the solution. Play around with simple examples ie 12/10 or 12%10 and see what the result is, and use that to buld up a solution.
 
Jesse Crockett
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this problem is a waste of time outside a math class.
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not at all. it is a very useful exercise for beginning programmers.

First thing is that programming is a mathematical discpline, even when not directly using math.

Secondly, and more importantly, it is a good exercise to learn how to problem solve. If you aren't a good problem solver, you aren't likely to be a good programmer.
[ June 08, 2006: Message edited by: Rusty Shackleford ]
 
Jesse Crockett
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's easier than I thought. I've done so much work with strings that I wanted to go about it that way. Thanks.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!