-
Python_Fibonacci_Sequence(피보나치 수열)연습코딩Coding/Mojo★Python파이썬_연습 2020. 6. 23. 22:26728x90
# Program to display the Fibonacci sequence up to n-th term nterms = int(input("How many term?")) # first two terms n1, n2 = 0, 1 count = 0 # check if the number of term is valid if nterms <= 0: print("Fibonacci sequence upto", nterms, ":") print(n1) else: print("Fibonacci sequence:") while count < nterms: print(n1) nth = n1 + n2 # update values n1 = n2 n2 = nth count += 1
결과
https://www.programiz.com/python-programming/examples/fibonacci-sequence
반응형'코딩Coding > Mojo★Python파이썬_연습' 카테고리의 다른 글
Python 패토리얼 예문 연습해보자 factorial (0) 2022.02.14 Python_if_else_and_or연습 (0) 2020.06.26 Python_if_elif_else예제 (0) 2020.06.23 Python_계산기초급 (0) 2020.06.21 Python_문자열 포맷팅_positional argument, keyword argument) (0) 2020.06.21 나만의 Function만들기(def로 정의함_Function_Syntax)2 (0) 2020.06.20 나만의 Function만들기(def로 정의함_Function_Syntax) (0) 2020.06.19 Python_Append_reverse연습 (0) 2020.06.19