Jump to content
Science Forums

Prime Obfusaction


Recommended Posts

don't ask how this began; but this is how it ended.

take a set of n coins, 100 say. let your total start at 0.

flip them.

count the number of heads and tails.

take the larger number as your score.

add the score to the total and flip the score number of coins.

rinse repeat until you get a single coin.

lets call this process a trial.

if a trial results in a prime number, record true. else record false.

the places where the true and falses lie, are roughly 72% accurate for the places where the primes and composites lie. the total number of trues will be roughly number of trials/ln(number of trails)

import random
primes = [False,False,True,True]+[False,True,False,True,False,False]*400
n = 5
while n*n<len(primes):
  x= int(len(primes)/n)
  while x >= n:
     if primes[x]:
        primes[x*n] = False
     x -= 1
  n += 1
  while not primes[n]:
     n += 1
isprime = [False]*1000
for i in range(1,1000):
  total = 0
  count = 100
  while count > 1:
     result = 0
     for j in range(0,count):
        result += random.randint(0,1)
     if result < count/2:
        count = count-result
     else:
        count = result
     total += count
  isprime[i] = primes[total]
total = 0
for i in range(0,1000):
  if isprime[i] == primes[i]:
     total += 1
print(total)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...