Question: Write a program to take two integer inputs from console. Number and N and print nth term in fibonacci series for the inputted Number. Fibonacci series :0,1,1,2,3,5,8,13,21,34,55,89,144 and so on. Example input : 5 3Example output:21 source code n1 = int(input()) n2 = int(input()) n_terms=n1+n2 n_1 = 0 n_2 = 1 count = 0 l=[] if n_terms == 1: l.append(n_terms) else: while count <= n_terms: l.append(n_1) nth = n_1 + n_2 n_1 = n_2 n_2 = nth count += 1 indexs=l.index(l[n1]) print(l[indexs+n2]) Categories: Coding Question Tags: #python #coding-question 0 Comments Leave a Reply Cancel replyYour email address will not be published. Required fields are marked * Name Email Website What's on your mind? Save my name, email, and website in this browser for the next time I comment. Δ
0 Comments