import time def hof(x): global z z+=1 if x == 1 or x == 2: return 1 else: 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(2),' # Aufrufe =',repr(z).rjust(10),' Zeitaufwand: {:5.3f} s'.format(end-start)) n += 1