Skip to content
Snippets Groups Projects
Commit 2a456010 authored by Taddeüs Kroes's avatar Taddeüs Kroes
Browse files

Cleanup

parent 544cbbcb
No related branches found
No related tags found
No related merge requests found
...@@ -2,30 +2,30 @@ ...@@ -2,30 +2,30 @@
# https://en.wikipedia.org/wiki/Continued_fraction#Some_useful_theorems # https://en.wikipedia.org/wiki/Continued_fraction#Some_useful_theorems
def nom(n): def nom(n):
nexth = hp = hpp = 1 h = hp = hpp = 1
while n > 0: while n > 0:
nexth = 2 * hp + hpp h = 2 * hp + hpp
hpp = hp hpp = hp
hp = nexth hp = h
n -= 1 n -= 1
return nexth return h
def denom(n): def denom(n):
kpp = 0 kpp = 0
nextk = kp = 1 k = kp = 1
while n > 0: while n > 0:
nextk = 2 * kp + kpp k = 2 * kp + kpp
kpp = kp kpp = kp
kp = nextk kp = k
n -= 1 n -= 1
return nextk return k
def ndig(n, base=10): def ndig(n, base=10):
i = 0 i = 1 if n == 0 else 0
while n > 0: while n > 0:
i += 1 i += 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment