Advertisement
Mochinov

Untitled

Aug 30th, 2021
1,082
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. import time
  2.  
  3. def prime_number():
  4.     result = '1'
  5.     num = 2
  6.     while len(result) <= 10000:
  7.         is_dev = False
  8.         for j in range(2, num):
  9.             if num % j == 0:
  10.                 is_dev = True
  11.         if not is_dev:
  12.             result += str(num)
  13.        
  14.         num += 1
  15.     return result[:10000]
  16.  
  17. def prime_number1(count_symbols):
  18.     result = '1'
  19.     num = 2
  20.     while len(result) <= count_symbols:
  21.         for j in range(2, num):
  22.             if num % j == 0:
  23.                 break
  24.         else:
  25.             result += str(num)
  26.        
  27.         num += 1
  28.     return result[:count_symbols]
  29.  
  30. start_time1 = time.time()
  31. prime_number1(10000)
  32. first = time.time() - start_time1
  33.  
  34.  
  35.  
  36. start_time1 = time.time()
  37. prime_number()
  38. second = time.time() - start_time1
  39.  
  40. print(first, second)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement