Skip to content

Instantly share code, notes, and snippets.

@DoctorMalboro
Last active October 11, 2015 04:07
Show Gist options
  • Save DoctorMalboro/3800114 to your computer and use it in GitHub Desktop.
Save DoctorMalboro/3800114 to your computer and use it in GitHub Desktop.
Python function that with the first 3 numbers returns a fibonacci sequence.
# 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