using recursion to print out odd numbers

so basically i'm extremely new to coding and i need help, i don't expect the exact fix, but a push in the right direction would be awesome. i need to edit this code in some way to make the odd numbers between 1 and 255 print. currently it prints out all the numbers from 1 to 255, but i just need the odd. any help would be appreciated, thanks a ton in advanced

Re: using recursion to print out odd numbers

Posted 03 October 2012 - 07:07 AM

To clarify a tiny bit, 5 % 2 will equal 1. This is because 5 divided by two is two with a remainder of 1. Similarly 6 % 2 will equal 0. This is because 6 divided by two is three with a remainder of 0. So, we can conclude that any number mod 2 will equal either 0 or 1.

Re: using recursion to print out odd numbers

Ha! I had always wondered what % did but hadn't reached that part in my book. So what if I wanted to divide something as well as get the remainder? Would you use 5 /% 2 ?

That would make a lot of sense, wouldn't it? It would return a tuple (quotient, remainder)!
Sadly, though, that's not in the language yet. Talk to Guido.
Until your eminently sensible suggestion is taken up, though, you have to perform two operations, a div and a mod.

Re: using recursion to print out odd numbers

Posted 03 October 2012 - 07:52 PM

jon.kiparsky, on 03 October 2012 - 09:41 PM, said:

That would make a lot of sense, wouldn't it? It would return a tuple (quotient, remainder)!
Sadly, though, that's not in the language yet. Talk to Guido.
Until your eminently sensible suggestion is taken up, though, you have to perform two operations, a div and a mod.

That's a darn shame. Oh well, one extra line of code for now isn't that big of a problem....yet.