项目作者: 8140171224

项目描述 :
Fibonacci in python/python3
高级语言: Python
项目地址: git://github.com/8140171224/fibonacci-Sequence.git
创建时间: 2019-05-07T06:07:28Z
项目社区:https://github.com/8140171224/fibonacci-Sequence

开源协议:

下载


define function fib: ‘fibonacci’

  1. def fib(n):

In fibonacci this is must reqd

  1. a, b = 0, 1

If elif else

In case someone only reqd one ouput

  1. if n == 1:
  2. print(a)

In case If someone given input in 0 or less

  1. elif n <= 0:
  2. print('not possible')

main block of code for fibonacci

  1. else:

For first two digits

  1. print(a)
  2. print(b)

For loop for the logic of fibonacci

  1. for i in range(2,n):
  2. c = a + b
  3. a, b = b, c

For printing less then or equals too of fib(n) input fib(10)

  1. if c <= n:
  2. print(c)
  3. else:
  4. break

fibonacci and input()

  1. fib(10)

Here I’m

Information

BY aakashpadhiyar

8140171224