Guest User

Pi Immediate Circle Search

a guest
Oct 15th, 2020
215
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pi = ''
  2.  
  3. with open('/path/to/pi.txt') as the_file: pi = the_file.read()      # This file should start without "3." in the front
  4.  
  5. for i in range(1, 200000):
  6.     #print(i)
  7.  
  8.     s = str(i)
  9.     end_of = len(pi.split(s)[0] + s)
  10.     end_of2 = len(pi.split(str(end_of))[0] + str(end_of))
  11.  
  12.     if end_of2 == i and end_of != i:
  13.         print('Number we are looking for: ' + str(i))
  14.         print(str(i) + ' first appears in Pi at the end of ' + str(end_of) + ' digits')
  15.         print(str(end_of) + ' first appears in Pi at the end of ' + str(end_of2) + ' digits\n')
  16.  
  17. """
  18. Pi:     40, 71
  19.  
  20. Phi:        356, 487, 1601, 14145
  21.  
  22. e:          27785, 45779
  23.  
  24. 2Pi:        No results
  25. """
RAW Paste Data