 All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars  perplexus dot info  Whadduzitdo? (Posted on 2005-01-14) Given positive, integer N, what does this algorithm produce?
```let S and D = N
repeat
let D = ⌊D/2⌋
subtract D from S
until D=0
produce S as the result```
Note: ⌊x⌋ represents the integer part of x.

For non-programmers: start with a positive, integer number (say, 19). Divide it by 2, discarding remainders, until you get to 0. (In this case, you'd get 9, 4, 2, and 1.) Sum all the quotients. (9+4+2+1=16.) Subtract the sum from the original number. (19-16=3.) What's the result?

 See The Solution Submitted by e.g. Rating: 3.7143 (7 votes) Comments: ( Back to comment list | You must be logged in to post comments.) very good, love the algorithmic view. | Comment 8 of 9 | thanx loved the problem bestproblem so far, THOUGH i didn't attemp to solve it, asin i was more interested in the inner workings of the problem and the how you solveitthan the actual solution.
 Posted by chris on 2005-02-26 06:53:51 Please log in:

 Search: Search body:
Forums (0)