Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132932 views
License: OTHER
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
5
def string(zahl):
6
if zahl <= 9:
7
return str(zahl)
8
else:
9
return chr(55+zahl)
10
11
12
def horner(b, Z):
13
ergebnis = ''
14
while Z > 0:
15
rest = Z % b
16
ergebnis = string(rest) + ergebnis
17
Z = (Z - rest)/b
18
return ergebnis
19
20
if __name__ == "__main__":
21
r = horner(16, 31562)
22
print("Result:" + str(r))
23
24