ABIX_Edukacja

horner-2n

Aug 19th, 2020
1,207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. # przykład do uruchomienia - definicja i wywołania
  2. #
  3. def testowa(stopien, lista_wsp, argument):
  4.     argument = argument * argument
  5.  
  6.     if stopien == 0:
  7.         return lista_wsp[stopien]
  8.     else:
  9.         return argument * testowa(stopien - 1, lista_wsp, argument) + lista_wsp[stopien]
  10.  
  11. wynik = testowa(3, [6, 8, -2, 23], 2)
  12. print(wynik)
  13. print(wynik==98831)
  14. #
  15. wynik = testowa(3, [6, 8, -2, 23], 5)
  16. print(wynik)
  17. print(wynik==36621218723)
  18. ##
  19. wynik = testowa(3, [6, 8, -2, 23], 2)
  20. print(wynik)
  21. print(type(wynik) is int)
  22. wynik = testowa(3, [6, 8, -2, 23], 5)
  23. print(wynik)
  24. print(type(wynik) is int)
Advertisement
Add Comment
Please, Sign In to add comment