mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
misc
This commit is contained in:
parent
e63c4f3335
commit
61d7185054
9 changed files with 228 additions and 2 deletions
20
source-code/Pseudocode/Horner-Schema/basiswechsel.py
Normal file
20
source-code/Pseudocode/Horner-Schema/basiswechsel.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/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))
|
Loading…
Add table
Add a link
Reference in a new issue