Advertisement
matrefeytontias

Untitled

May 29th, 2017
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. # Deux suites "aléatoires" (mash de clavier)
  2. x = lambda n : [ 5, 1, 8, 1, 23, 1, 5, 9, 7, 41 ][n] if n < 10 and n >= 0 else 0
  3. y = lambda n : [ 8, 4, 6, 7, 1, 2, 5 ][n] if n < 7 and n >= 0 else 0
  4.  
  5. # w_n(k), la convolution dans Z/nZ
  6. def w(n, k):
  7.     r = 0
  8.     for i in range(n):
  9.         r += x(i % n) * y((k - i) % n)
  10.     return r
  11.  
  12. # v(n), la convolution tout court
  13. def v(n):
  14.     r = 0
  15.     for i in range(n - 6, 10):
  16.         r += x(i) * y(n - i)
  17.     return r
  18.  
  19. print(w(20, 18)) # c'est bien 0 !
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement