From 8e431d287c0e89041506da4c4da57e3e3d657d72 Mon Sep 17 00:00:00 2001 From: mjfernez Date: Mon, 3 Feb 2020 23:04:10 -0500 Subject: cleanup, added c translations for some --- fib.py.orig | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 fib.py.orig (limited to 'fib.py.orig') diff --git a/fib.py.orig b/fib.py.orig new file mode 100644 index 0000000..77b32fa --- /dev/null +++ b/fib.py.orig @@ -0,0 +1,33 @@ +import PIL, math +MAX = 4*10**6 + +#Problem 2 Even Fibonnacci numbers +fib = [1, 1] + +k=1; +while (True): + n = fib[k] + fib[k-1] + if(n>MAX): + break + else: + fib.append(n); + k+=1 + +c=0 +for i in fib: + num = str(i) + print(num + " ", end='') + c+=1 + if(c%10==0): + print() + +print() + +print("The sum is: " + str(sum(fib))) + +s=0 +for i in fib: + if (i%2==0): + s+=i + +print("The sum of the even terms is: " + str(s)) -- cgit v1.2.3