Skip to content

Instantly share code, notes, and snippets.

@neoneye
Last active November 27, 2020 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neoneye/a347d1ddacd4b9d172c091f6f000e8d9 to your computer and use it in GitHub Desktop.
Save neoneye/a347d1ddacd4b9d172c091f6f000e8d9 to your computer and use it in GitHub Desktop.
Reconstructing the primes from the Prime-Representing Constant 2.920050977316
# 2.920050977316 - A Prime-Representing Constant
# by Dylan Fridman, Juli Garbulsky, Bruno Glecer, James Grime, Massi Tron Florentin
#
# Numberphile
# https://www.youtube.com/watch?v=_gCKX6VMvmU
#
# Article
# https://arxiv.org/abs/2010.15882
#
# OEIS sequence
# https://oeis.org/A249270
#
# Wikipedia
# https://en.wikipedia.org/wiki/Formula_for_primes#A_function_that_represents_all_primes
require 'bigdecimal'
a249270 = [2, 9, 2, 0, 0, 5, 0, 9, 7, 7, 3, 1, 6, 1, 3, 4, 7, 1, 2, 0, 9, 2, 5, 6, 2, 9, 1, 7, 1, 1, 2, 0, 1, 9, 4, 6, 8, 0, 0, 2, 7, 2, 7, 8, 9, 9, 3, 2, 1, 4, 2, 6, 7, 1, 9, 7, 7, 2, 6, 8, 2, 5, 3, 3, 1, 0, 7, 7, 3, 3, 7, 7, 2, 1, 2, 7, 7, 6, 6, 1, 2, 4, 1, 9, 0, 1, 7, 8, 1, 1, 2, 3, 1, 7, 5, 8, 3, 7, 4, 2, 2, 9, 8, 3]
a249270string = a249270.join('').insert(1, '.')
state = BigDecimal(a249270string)
primes = []
50.times do
prime = state.floor
state = prime * (state + 1 - prime)
primes << prime
end
p primes
# output:
# [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment