Hi all, I was experimenting with techniques of generating random numbers and eventually decided on the following. I realize there's a big discussion in computing circles about "randomness" and as such am not trying to make any claims here. What do you think? Thoughts, comments, suggestions, discussion of underlying theories, and even your own version of random generators are welcome! Here's the code:
def primes(n):
s = range(3, n+1, 2)
i = 1
a = len(s) - 1
for l in xrange(0, a + 1):
a1 = i
j = (l + (s[l]*i))
while (j <= a) and s[l] != 0:
s[j] = 0
i += 1
j = (l + (s[l]*i))
i = a1 + 1
s = list(set(s))
s.sort()
if 0 in s:
s.remove(0)
s = [2] + s
return s
import time as t
a = t.time() - int(t.time())
b = "%.6f" % a
b = b.split('0.')[1]
n = int(b)
s = primes(n)
l = len(b) + 1
S = 0
for k in range(1, l):
if b[:k] not in s:
S += int(b[:k])
print "The non-prime sum 'S' --> ",S
k = 1
l = int(b[:1])
n = int(b[0])
while S > 100:
S = float(S/(s[l] + n*k))
k += 1
print "S -->", S, "|", "Decimal part of S -->", S - int(S), "|", "Decimal part of time when program began -->", a