From 1b55f9d7c8787d39f9359f053939a899a4d5a782 Mon Sep 17 00:00:00 2001 From: keerthi-chamarthi <42383117+keerthi-chamarthi@users.noreply.github.com> Date: Mon, 29 Oct 2018 21:27:59 -0700 Subject: [PATCH] fib sequence generation used only two variables --- fib.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 fib.py diff --git a/fib.py b/fib.py new file mode 100644 index 0000000..7447fb4 --- /dev/null +++ b/fib.py @@ -0,0 +1,17 @@ +n=int(input()) +a=0 +b=1 +if(n==1): + print("0") +elif(n==2): + print("0 1") +else: + print("0 1",end=' ') + while((n-2)>0): + b=a+b + a=b-a + if(n==1): + print(b) + else: + print(b,end=' ') + n-=1