basiswechsel.py 395 B

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