a function that returns a random number that is a multiple of 3 between 0 and the function's non-negative integer parameter n
Posted
by
martin
on Stack Overflow
See other posts from Stack Overflow
or by martin
Published on 2012-09-20T21:26:30Z
Indexed on
2012/09/20
21:37 UTC
Read the original article
Hit count: 157
I need to write a function called multipleOf3
that returns a random number that
is a multiple of 3 between 0 and the function's non-negative integer
parameter n
and here is the result i want [Note: No number returned can be greater than the value of the
parameter n
]
Examples:
multipleOf3(0) -- 0
multipleOf3(1) -- 0
multipleOf3(2) -- 0
multipleOf3(3) -- 0 or 3
multipleOf3(20) -- 0 or 3 or 6 or 9 or 12 or 15 or 18
© Stack Overflow or respective owner