20201205, 01:58  #1 
Dec 2017
2^{4}·3·5 Posts 
Semiprime Squared Prime Test ¿
If you guys don't like this than you all must hate primes and I'm leaving. This little puppy code produces primes up the ying yang and if you know how to code then you can remove the prime checker and see if the outputs for Huge primes produce too and I feel they do! Code:
print('''SemiPrime Squared Prime test, Good for 5 digits and a little more on input!''') import time while True: start_time = time.time() p = int(input("Enter a prime number: ")) a = (((p*5)**2)2) c = (((p*2)**2)+1) e = (((p*3)**2)2) g = (((p*7)**2)2) i = (((p*11)**2)20) k = (((p*13)**2)2) b = (p*5) d = (p*2) f = (p*3) h = (p*7) j = (p*11) l = (p*13) def isPrime(n) : # Corner cases if (n <= 1) : return False if (n <= 3) : return True # This is checked so that we can skip # middle five numbers in below loop if (n % 2 == 0 or n % 3 == 0) : return False i = 5 while(i * i <= n) : if (n % i == 0 or n % (i + 2) == 0) : return False i = i + 6 return True # Driver Program if (isPrime(a)) : print("a PRIME!",a,'a') else : print("a false",a,'a') if(isPrime(a)) : print("a PRIME!",a,'a') else : print("a false",a,'a') print(b,'bSemiprime product always of Five') if (isPrime(c)) : print("c PRIME!",c,'c') else : print("c false",c,'c') if(isPrime(c)) : print("c PRIME!",c,'c') else : print("c false",c,'c') print(d,'dSemiprime product always of Two') if (isPrime(e)) : print("e PRIME!",e,'e') else : print("e false",e,'e') if(isPrime(e)) : print("e PRIME!",e,'e') else : print("e false",e,'e') print(f,'fSemiprime product always of Three') if (isPrime(g)) : print("g PRIME!",g,'g') else : print("g false",g,'g') if(isPrime(g)) : print("g PRIME!",g,'g') else : print("g false",g,'g') print(h,'hSemiprime product always of Seven') if (isPrime(i)) : print("i PRIME!",i,'i') else : print("i false",i,'i') if(isPrime(i)) : print("i PRIME!",i,'i') else : print("i false",i,'i') print(j,'jSemiprime product always of Eleven') if (isPrime(k)) : print("k PRIME!",k,'k') else : print("k false",k,'k') if(isPrime(i)) : print("k PRIME!",k,'k') else : print("k false",k,'k') print(l,'lSemiprime product always of Thirteen') print('If Top Prime and Bottom false, than its Prime') e = int(time.time()  start_time) print('{:02d}:{:02d}:{:02d}'.format(e // 3600, (e % 3600 // 60), e % 60)) 
20201205, 03:17  #2 
Undefined
"The unspeakable one"
Jun 2006
My evil lair
2·3·1,019 Posts 

20201205, 04:21  #3 
Dec 2017
2^{4}·3·5 Posts 
I just spotted something about this code.
Test any number one before a Twin Prime and the middle of twins and just one after the Twins and don't forget to test the Twins you often always get a Prime output and for some odd reason you don't the next prime produces a prime. 
20201205, 07:54  #4  
Jan 2012
Toronto, Canada
3×19 Posts 
Quote:
So please do us all a favor and start educating yourself on some Python/coding/number theory basics before you make another thread on this forum. It'll make both your time and our time much more productive. 

20201205, 08:01  #5 
Undefined
"The unspeakable one"
Jun 2006
My evil lair
1011111100010_{2} Posts 
I use tab characters. And my tab width is 8.
You can all hate me now, I don't care. Eight is the "correct" number, always. No need for all those wasteful spacespacespacespacespacespacespacespace... things, using up the precious HDD capacity. Every byte matters. 
20201205, 08:15  #6 
Jan 2012
Toronto, Canada
71_{8} Posts 
That's actually a fair point, I think there is a heuristic for HTML pages where the ones that are written using tabs are 515% smaller and takes similarly less time to load. Or maybe you have a script with tens of thousands of lines where that might actually make a difference. I guess it isn't necessarily universal even among Python developers but it's in the official style guidelines (PEP 8).
Funnily I came upon this while doing a quick search... https://stackoverflow.blog/2017/06/1...oneyusetabs/ 
20201205, 08:39  #7  
Undefined
"The unspeakable one"
Jun 2006
My evil lair
2·3·1,019 Posts 
Quote:
Quote:


20201206, 00:55  #8  
Dec 2017
240_{10} Posts 
Quote:


20201206, 06:45  #9 
Aug 2006
3^{2}×5×7×19 Posts 
Let me break this down. You have 12 polynomials in p (let's suppose this is prime), six of which are quadratic and six of which are linear (constant multiples of p, in fact). But it's pretty obvious that a prime multiple of a prime will be semiprime, so that's true but trivial, and the quadratics will be less than 10% prime, less than 1% prime, less than 0.0000001% prime, ..., by sieve theory. (More can be said, conjecturally, about the relative density of the primes in each, though. Interested?)
Aside: Your code really needs work; you should have a function, say "test", where you can just call test(25*p**2  2, 'a') and have the appropriate things done. Or better yet, scrap the need for the second argument entirely and apply the function directly to an array, like so: Code:
def test(n): # function definition goes here valuesToTest = [25*p**22, 4*p**2+1, 9*p**22, 49*p**22, 121*p**220, 169*p**22] results = map(test, valuesToTest) Code:
def test(n): # function definition goes here initialPrimes = [2, 3, 5, 7, 11, 13] offsets = [1, 2, 2, 2, 20, 2] valuesToTest = [ q*p for q in initialPrimes ] valuesToTest = [ k**2 for k in valuesToTest ] valuesToTest = [sum(x) for x in zip(valuesToTest, offsets)] results = map(test, valuesToTest) 
Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Semiprime and Prime Generator  ONeil  ONeil  2  20201201 04:14 
Semiprime and nalmost prime candidate for the k's with algebra for the Sierpinski/Riesel problem  sweety439  sweety439  11  20200923 01:42 
...factorial(n) plus/minus 1 is semiprime  enzocreti  enzocreti  3  20200902 16:35 
Semiprime counting  danaj  Computer Science & Computational Number Theory  12  20181014 03:16 
Primorials squared primes?  siegert81  Math  6  20101228 15:17 