import time def hof(x): global z z+=1 if x == 1: return 1 elif x == 2: return 1 elif x > 2: return hof(x - hof(x - 1)) + hof(x - hof(x - 2)) endwert = int(input('Bis zu welchem Wert soll Hofstadter berechnet werden? ')) n = 1 while n <= endwert: z = 0 start = time.time() y = hof(n) end = time.time() print('hof(',repr(n).rjust(2),') =',repr(y).rjust(3),' # Aufrufe =',repr(z).rjust(12),' Zeitaufwand: {:7.3f} s'.format(end-start)) n += 1