The following function returns the Nth multiple of 4. What is N ?
# python code start
def calc_nth_multiple_of_4():
i = 0
n = 0
while (n < 11):
i += 1
if (i % 4 == 0):
n += 1
return i
Details and assumptions
The 1st multiple of 4 is 4 .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The answer is 11 . This code iterates through integers i , and uses n to keep track of how many multiples of 4 we find. Once n == 11, the loop exits, and i contains the 11th multiple of 4. The function then returns i .