« Return to Thread: generating random odd integer

Re: generating random odd integer

by Felix Schäfer :: Rate this Message:

Reply to Author | View in Thread



Am 09.07.2009 um 13:20 schrieb Ghazal Mir:

> how can i generate random odd integers?

Something like: 2 * rand(6) + 1 ? The example will give you an odd  
number between 1 and 11 (both included). Adapt the number in rand as  
needed.

More details here http://ruby-doc.org/core/classes/Kernel.html#M005974

As a side note: Google is your friend.

Felix

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

 « Return to Thread: generating random odd integer