-4

# Where am i wrong

Fibbonacci

11/24/2020 4:06:15 AM

Thakkar Heer

+3

THAKKAR HEER two people have already posted working solutions. And YOU still have not linked your own code. How do you expect people to help you figure out what is wrong in your code, if we can't see it? We are not mind readers.

+3

You also don't need to end nearly every line with a colon. https://code.sololearn.com/c3DX0O0ws415/?ref=app

+3

Your working code here def recur_fibo(n): if n <= 1: return n else: return(recur_fibo(n-1)+recur_fibo(n-2)) nterms=10 if nterms<=0: print("please enter a positive integer") else: print("fibonacci sequence") for i in range(nterms): print (recur_fibo(i)) Indentation problems and colons at the end of lines 3,5,9,11 were causing the problem

+3

No worries, take it easy. Good thing you figured it out π

+2

Indentation. You need to align the beginning of the rows correctly with whitespace, so that python understands the block structure of your code. You'd better save it on code playground and provide a link here, it will be easier for people to help.

+2

What do you mean the output is the same? It's a fibonacci sequence it should always be the same sequence up to a given number of iterations.

+2

are you good with the indentation yet?

+2

A fibonacci sequence by definition starts from 0, so not sure what your issue is. https://www.mathsisfun.com/numbers/fibonacci-sequence.html

+1

I mean in the question the output is not fibonacci sequence and starts from 0 but in my output is fibonacci and then starts from 0

+1

Sorry guys i solved it

0

def recur_fibo(n): if n<= 1: return n: else: return(recur_fibo(n-1)+recur_fibo(n-2)): nterms=10 if nterms<=0: print("please enter a positive integer"): else: print("fibonacci sequence"): for i in range(nterms): print (recur_fibo(i))

0

It is working but the output is same

0

0

0

I was not putting correct indentations

0

Sorryπ­π­π­π­

-1
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}