mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-19 11:38:05 +02:00
20 lines
393 B
Python
20 lines
393 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
def string(zahl):
|
|
if zahl <= 9:
|
|
return str(zahl)
|
|
else:
|
|
return chr(55+zahl)
|
|
|
|
def horner(b, Z):
|
|
ergebnis = ''
|
|
while Z > 0:
|
|
rest = Z % b
|
|
ergebnis = string(rest) + ergebnis
|
|
Z = (Z - rest)/b
|
|
return ergebnis
|
|
|
|
if __name__ == "__main__":
|
|
r = horner(16, 31562)
|
|
print("Result:" + str(r))
|