Created
December 22, 2010 03:39
-
-
Save fzmaster/751054 to your computer and use it in GitHub Desktop.
Encontrar enésimo número de Fibonnaci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
def fibonnaci(numero): | |
""" | |
Autor: fzmaster | |
Data: 22/12/2010 | |
Problema: Fibonnaci Killer | |
http://codingkata.org/katas/unit/fibonacci-killer | |
Calcular enesimo numero de Fibonnaci | |
""" | |
if numero == 0: | |
return 0 | |
elif numero == 1: | |
return 1 | |
else: | |
return fibonnaci(numero-1)+fibonnaci(numero - 2) | |
class FKTestCase(unittest.TestCase): | |
def test_FB0(self): | |
assert fibonnaci(0) == 0 | |
def test_FB1(self): | |
assert fibonnaci(1) == 1 | |
def test_FB2(self): | |
assert fibonnaci(2) == 1 | |
def test_FB3(self): | |
assert fibonnaci(3) == 2 | |
def test_FB16(self): | |
assert fibonnaci(16) == 987 | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment