Last active
October 11, 2015 04:07
-
-
Save DoctorMalboro/3800114 to your computer and use it in GitHub Desktop.
Python function that with the first 3 numbers returns a fibonacci sequence.
This file contains 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
# coding: utf-8 | |
from __future__ import print_function | |
def fibonacci(num1, num2, loop): | |
""" | |
Arguments: | |
num1 (int) = first number | |
num2 (int) = second number | |
loop (int) = the amount of times it iterates | |
""" | |
j = 0 | |
print(num1) | |
print(num2) | |
while j < loop: | |
num3 = num1 + num2 | |
print(num3) | |
num1 = num2 | |
num2 = num3 | |
j = j + 1 | |
if __name__ == '__main__': | |
num1 = input('Número 1: ') | |
num2 = input('Número 2: ') | |
cant = input('Cantidad: ') | |
fibonnaci(num1, num2, cant) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment