mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Blogorrhea > ONeil

Reply
 
Thread Tools
Old 2020-11-30, 23:52   #1
ONeil
 
Dec 2017

24010 Posts
Minus 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
ONeil is offline   Reply With Quote
Old 2020-12-01, 03:47   #2
Dylan14
 
Dylan14's Avatar
 
"Dylan"
Mar 2017

58610 Posts
Default

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.
Dylan14 is offline   Reply With Quote
Old 2020-12-01, 04:14   #3
ONeil
 
Dec 2017

24·3·5 Posts
Default

Thanks Dylan
ONeil is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Semiprime and n-almost prime candidate for the k's with algebra for the Sierpinski/Riesel problem sweety439 sweety439 11 2020-09-23 01:42
prime generator for f(n)=n^2+1 bhelmes Miscellaneous Math 2 2016-03-17 17:50
New prime test (or generator) synergy Miscellaneous Math 39 2004-09-21 17:10
Prime Number Generator Unregistered Programming 6 2004-03-21 01:00
twin prime generator 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

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.