BERKYT

Untitled

Dec 16th, 2021 (edited)
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. def congruence(x):
  2.     list_nums = []
  3.     list_index = []
  4.    
  5.     for index in range(x):
  6.         m = random.randint(1, 1000) * 2
  7.         a = random.randint(1, 1000) * 2 + 1
  8.         x0 =random.randint(1, 1000) * 2 + 1
  9.         x_i = (a * x0 - 1) % m
  10.         r_i = x_i / m
  11.         print( r_i, index)
  12.         list_nums.append(r_i)
  13.         list_index.append(index)
  14.        
  15.     return list_nums, list_index
  16.  
  17.  
  18. def random_(x):
  19.     list_nums = []
  20.     list_index = []
  21.    
  22.     for index in range(x):
  23.         m = random.random()
  24.         print(m, index)
  25.         list_nums.append(m)
  26.         list_index.append(index)
  27.        
  28.     return list_nums, list_index
  29.  
  30.  
  31. tuple_cords_congruence = congruence(int(input('Конгруэнтный метод. Введите число: ')))
  32. tuple_cords_random = random_(int(input('Рандомный метод. Введите число: ')))
  33. print(tuple_cords_congruence)
  34. print(tuple_cords_random)
Add Comment
Please, Sign In to add comment