Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

피보나치/임인택

From ZeroWiki
def pibo(num):
	if num == 1 or num == 2 :
		return 1
	else:
		return pibo(num-1)+pibo(num-2)

#using iteration w/o array (or anytype like array)
def piboIter(num):
    if num <= 2 :
        return 1

    a = b = c = 1
    for i in range(0, num-2):
        c = a + b
        a = b
        b = c
    return c