Re: OT: C++ Recursion [message #192156 is a reply to message #192146] |
Tue, 07 March 2006 21:56   |
 |
Ryan3k
Messages: 363 Registered: September 2004 Location: USA
Karma:
|
Commander |
|
|
CPUKiller has pretty much got it, I don't know C++ myself, but I know Java, and all you need to know is that the '%' operator is for modular division, and it gives you the remainder of a/b.
For example,
10 % 3 = 1
10 % 10 = 0
12 % 5 = 2
Another important note is that because it is an int, it will truncate decimals. In the first runthrough of ValueOf, when you divide 11 by 2, you get 5.5, right? Well, it won't round it up to 6. It truncates the decimal, and you end up with 5.
5 becomes the new 'N', passed as parameter to ValueOf... etc. etc.
A Path Beyond
|
|
|