Advertisement
4eyes4u

NI grafovi | Source code

Sep 23rd, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. def fac(n):
  5.     ret=1
  6.     for i in range(2, n+1): ret*=i
  7.     return ret
  8.  
  9. memo={}
  10. def f2(n):
  11.     if (n<5): return 1
  12.     if (n not in memo): memo[n]=f2(n-1)+(n-1)*(n-2)*(n-3)*(n-4)*f2(n-5)
  13.     return memo[n]
  14.  
  15. def t(n):
  16.     ret=f2(n)/fac(n)
  17.     print(ret)
  18.     return ret
  19.  
  20. plt.plot([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100], [t(1), t(2), t(3), t(4), t(5), t(6), t(7), t(8), t(9), t(10), t(11), t(12), t(13), t(14), t(15), t(16), t(17), t(18), t(19), t(20), t(21), t(22), t(23), t(24), t(25), t(26), t(27), t(28), t(29), t(30), t(31), t(32), t(33), t(34), t(35), t(36), t(37), t(38), t(39), t(40), t(41), t(42), t(43), t(44), t(45), t(46), t(47), t(48), t(49), t(50), t(51), t(52), t(53), t(54), t(55), t(56), t(57), t(58), t(59), t(60), t(61), t(62), t(63), t(64), t(65), t(66), t(67), t(68), t(69), t(70), t(71), t(72), t(73), t(74), t(75), t(76), t(77), t(78), t(79), t(80), t(81), t(82), t(83), t(84), t(85), t(86), t(87), t(88), t(89), t(90), t(91), t(92), t(93), t(94), t(95), t(96), t(97), t(98), t(99), t(100)])
  21.    
  22. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement