2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-26 06:48:04 +02:00

Fix Python code style

This commit is contained in:
Martin Thoma 2015-11-20 22:36:38 +01:00
parent bd1f36e90c
commit 59b3d42774
5 changed files with 134 additions and 96 deletions

View file

@ -1,7 +1,22 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def euklid(b, Z):
"""
Euclids algorithm to change the basis.
Returns
-------
dict
A dictionary mapping the i-th position of the new number to its value,
where higher numbers are more significant.
Examples
--------
>>> euklid(3, 5)
{1: 1, 0: 2}
"""
p = 0
while b**p <= Z:
p = p+1
@ -9,14 +24,14 @@ def euklid(b, Z):
y = {}
while Z != 0 and i > -5:
y[i] = Z // b**i
y[i] = Z // b**i
R = Z % b**i
Z = R
i = i -1
i = i - 1
return y
if __name__ == "__main__":
r = euklid(16, 15741.233)
print("Result:")
for key in sorted(r.iterkeys(),reverse=True):
for key in sorted(r.iterkeys(), reverse=True):
print "%s: %s" % (key, r[key])