mersenneforum.org Semiprime and Prime Generator
 Register FAQ Search Today's Posts Mark Forums Read

 2020-11-30, 23:52 #1 ONeil   Dec 2017 24010 Posts Semiprime and Prime Generator MODERATOR NOTE: Please confine your posts to your blog area. This is very interesting, because the output is always a Prime number or a Semiprime number. My Python code is very special for all you who thought numerology was a lost cause. I say that the cranks can find something every once in a while. So to all you Grinch's out there don't count me out yet lol. Code: import time while True: p = int(input('Enter a number greater than zero: ')) print('__________________________________________________') n = (((p - 1) % 9 + 1 if p else 0)) s = ((((p+2) - 1) % 9 + 1 if p else 0)) start_time = time.time() print((n*s)-1,'Is this number a Semiprime or Prime Number?') e = int(time.time() - start_time) print('___________________________________________') print('{:02d}:{:02d}:{:02d}'.format(e // 3600, (e % 3600 // 60), e % 60)) Last fiddled with by ONeil on 2020-12-01 at 00:58 Reason: Moderator note
 2020-12-01, 03:47 #2 Dylan14     "Dylan" Mar 2017 58610 Posts Indeed your code does indeed produce a prime or semiprime for any positive input: I modified your code a bit: Code: import time p = 1 start_time = time.time() while p <= 1000: n = (((p - 1) % 9 + 1 if p else 0)) s = ((((p+2) - 1) % 9 + 1 if p else 0)) print(p, n, s, (n*s)-1) p += 1 e = int(time.time()-start_time) print('{:02d}:{:02d}:{:02d}'.format(e // 3600, (e % 3600 // 60), e % 60)) From the output we get the following cycle of results: Code: 2 7 14 23 34 47 62 7 17 and then it repeats. 2, 7, 17, 23, 47 are indeed prime. 14 = 2*7 is a semiprime, 34 = 2*17 is a semiprime, and 62 = 2*31 is a semiprime. Now, is this a profound result? No, it's not, but it's cool, I guess.
 2020-12-01, 04:14 #3 ONeil   Dec 2017 24·3·5 Posts Thanks Dylan

 Similar Threads Thread Thread Starter Forum Replies Last Post sweety439 sweety439 11 2020-09-23 01:42 bhelmes Miscellaneous Math 2 2016-03-17 17:50 synergy Miscellaneous Math 39 2004-09-21 17:10 Unregistered Programming 6 2004-03-21 01:00 1260 Math 13 2003-10-12 09:48

All times are UTC. The time now is 18:08.

Mon Oct 25 18:08:43 UTC 2021 up 94 days, 12:37, 0 users, load averages: 0.94, 1.39, 1.39