Advertisement
PaweU

afaef

Dec 10th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Mon Dec 10 19:42:53 2018
  4.  
  5. @author: pytlpawe
  6. """
  7. import math
  8.  
  9. lista = [5, 7, 4, 18, 3, 7, 5, 1, 2, 12, 7, 13]
  10. podejrzane = []
  11.  
  12.  
  13. def LiczbyPierwsze (lista):
  14. for i in range (len(lista)):
  15. if (lista[i] < 2):
  16. podejrzane.append (lista[i])
  17. elif (lista[i] > 2):
  18. Prime = 1
  19. for j in range (2, int(math.sqrt(lista[i]))+1):
  20. if (lista[i]%j == 0):
  21. Prime = 0
  22. break
  23. if Prime == 1:
  24. podejrzane.append (lista[i])
  25.  
  26. def wyst_np (lista, podejrzane):
  27. for i in range (len(lista))
  28.  
  29.  
  30.  
  31. # -*- coding: utf-8 -*-
  32. """
  33. Created on Mon Dec 10 19:21:30 2018
  34.  
  35. @author: pytlpawe
  36. """
  37. import time
  38.  
  39.  
  40.  
  41. wartosci = []
  42.  
  43. def tab (n):
  44. for i in range (n+1):
  45. wartosci.append (-1)
  46.  
  47. def fibo (n):
  48. if (wartosci [n] != -1):
  49. return wartosci [n]
  50. else:
  51. if n==0:
  52. wartosci [n] = 0
  53. return wartosci [n]
  54. elif n==1:
  55. wartosci [n] = 1
  56. return wartosci [n]
  57. elif n>1:
  58. wartosci [n] = fibo (n-1) + fibo (n-2)
  59. return wartosci [n]
  60.  
  61.  
  62. def function (n):
  63. tab (n)
  64. return fibo (n)
  65.  
  66. start_r = time.time()
  67.  
  68. liczba = function (14)
  69. print (liczba)
  70. print ("Obliczenie zajelo", time.time() - start_r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement