Skip to content

Instantly share code, notes, and snippets.

@setajampisau
Created December 2, 2014 20:28
Show Gist options
  • Save setajampisau/bf46ed531085b2f1dda1 to your computer and use it in GitHub Desktop.
Save setajampisau/bf46ed531085b2f1dda1 to your computer and use it in GitHub Desktop.
Ödev
def fib(n):
dizi = []
a,b = 1,1
for j in range(n-1):
dizi.append(a)
a,b = b,a+b
return dizi
## Decmal to Fibonacci Sequence
def dec2fib(decimal):
sayi = decimal
i = 1
dizi_taban = []
while decimal > 0:
while fib(i) < decimal:
i += 1
i -= 1
dizi_taban.append(fib(i))
decimal -= fib(i)
i = 1
print (dizi_taban[-1], " ", end=="")
print dec2fib(10000)
## Fibonacci Sequence to Decimal
k = []
def fibotodec(n):
if n >= 0:
k = map(int, str(n))
a = 1
b = 2
c = a + b
fib = [a,b,a+b]
m = 0
n = 1
toplam = 0
while len(k) > len(fib):
a, b, c = b, c, a + b
fib.append(c)
fib = fib[::-1]
t = 0
i = 0
while len(k) > t:
m = fib[i] * k[t]
toplam = toplam + m
ı = ı + 1
t = t + 1
return toplam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment