Advertisement
Guest User

A formula that generates the first prime numbers

a guest
Feb 20th, 2020
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. from math import *
  2.  
  3. def f(x):
  4.     return floor(cos(x*fmod(2.49059,0.442822*x))-0.802418+2*x+0.0902119*x*x)
  5.  
  6. for x in range(1, 30):
  7.     print x, f(x)
  8.    
  9. '''
  10. This prints:
  11.  
  12. 1 2.0
  13. 2 3.0
  14. 3 5.0
  15. 4 7.0
  16. 5 11.0
  17. 6 13.0
  18. 7 17.0
  19. 8 21.0
  20. 9 23.0
  21. 10 29.0
  22. 11 31.0
  23. 12 36.0
  24. 13 41.0
  25. 14 43.0
  26. 15 50.0
  27. 16 53.0
  28. 17 59.0
  29. 18 65.0
  30. 19 68.0
  31. 20 76.0
  32. 21 80.0
  33. 22 86.0
  34. 23 93.0
  35.  
  36. Software used to generate the formula: TuringBot
  37.  
  38. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement