mersenneforum.org  

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

Reply
 
Thread Tools
Old 2020-11-13, 17:16   #12
Dr Sardonicus
 
Dr Sardonicus's Avatar
 
Feb 2017
Nowhere

22·7·149 Posts
Default

Quote:
Originally Posted by retina View Post
Yes, they are speed-up computations.

So whenever someone says it isn't fast enough, then you just remove one of them and now it is faster. It's pure genius!
Good one! I guess that could also be called "padding."

A generally descriptive word for "intended to cause delay or waste time" is "dilatory."
Dr Sardonicus is offline   Reply With Quote
Old 2020-11-13, 17:23   #13
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

3,541 Posts
Default

Quote:
Originally Posted by retina View Post
Yes, they are speed-up computations.

So whenever someone says it isn't fast enough, then you just remove one of them and now it is faster. It's pure genius!
I seem to remember NOP as this type of command somewhere in my distant past. . .
EdH is offline   Reply With Quote
Old 2020-11-13, 21:43   #14
Dr Sardonicus
 
Dr Sardonicus's Avatar
 
Feb 2017
Nowhere

22·7·149 Posts
Default

Quote:
Originally Posted by EdH View Post
I seem to remember NOP as this type of command somewhere in my distant past. . .
If NOP isn't exactly what I was thinking of, it's close enough as makes no nevermind. It doesn't actually "calculate" anything, but the instruction does occupy space in the code, and its execution does take time. By putting some NOP instructions in code, you create space that could later be used to insert instructions that do something, preserving the relative positions of the other instructions.

If a small section of code is doing something you don't want it to do, I suppose you could obliterate it with NOP instructions, thereby preserving the relative positions of surrounding instructions in the code.

I suppose creating a time delay by inserting a NOP could be useful in some circumstances.

But in the Python code in the initial post to this thread, there are at least two types of calculations that (at best) don't accomplish anything. One is multiplying an integer expression by a nonzero integer constant, then dividing the product by the same constant. Another is adding a term to an expression, then subtracting the same term.

I note that these calculations only fail to change anything because they are being done with exact numbers. Doing these things with approximate number types can result in an output different from the input. (I suppose that, even in arithmetic with exact numbers, one of the superfluous operations could cause an overflow.)
Dr Sardonicus is offline   Reply With Quote
Old 2020-11-14, 14:34   #15
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

3,541 Posts
Default

We seem to be drifting from the subject, but I'll continue the drift with a short story:

Back when I was dabbling with assembly code for TI-99/4(A) home computers, there was a magazine that ran a contest to supply the answer to a math problem in the shortest length of time using whatever available language you preferred.

I coded up a solution in assembly but don't think I ever sent it in. I just waited for the next issue to compare. At this point I don't even remember if I did well against the winner or not.

But, the article was interesting. The program with the fastest time, an impressive value, was not the winner. It was "honorably" noted as the fastest to provide the answer, but that was because the entire code consisted of a short delay prior to an instruction to print the answer.
EdH is offline   Reply With Quote
Old 2020-11-14, 14:59   #16
Dr Sardonicus
 
Dr Sardonicus's Avatar
 
Feb 2017
Nowhere

22×7×149 Posts
Default

OK, back to the topic:

If my understanding of Python operators and operator priorities is correct, if the proffered code runs without error,

t = (((2*n)//2)) + ((3*(n+2)//3)) is 2*n+2,

ttl = (((2*n)//2)) + ((3*(n+2)//3)) + (((2*n+3))) - ((3*(n+2)//3)) is 3*n+3,

ta = (((2*n)//2)) is n, and

tb = ((3*(n+2)//3)) is n+2.

Since the computations are only done if n is odd,

ttl%6 is 0, and

t%8 is 4 if (n+1)/2 is odd, and 0 if (n+1)/2 is even
Dr Sardonicus is offline   Reply With Quote
Old 2020-11-14, 15:00   #17
mathwiz
 
Mar 2019

11×13 Posts
Default

Has nobody commented on the program's kick ass speed?? It can add two, then multiply by two, then divide by two in record time!
mathwiz is offline   Reply With Quote
Old 2020-11-26, 07:43   #18
ONeil
 
Dec 2017

24×3×5 Posts
Arrow Lastest Code a TWIN PRIME

Check it out!


Code:
import time
print('''If its easier to understand, start by looking at the ZONE or EATER, then read
all the rules! This code should weed out composite numbers and help
indicate Prime numbers or Twin Primes.  The code works for a
0 ZONE or 0 EATER!''')
print('**********************************************************************************')	

while True:
	p = int(input('Is this number Prime?: '))
	print('__________________________________________________')
	if p % 2 and p % 5 != 0:
		
		
		
		n = (((p - 1) % 9 + 1 if p else 0)-9)
		s = (n*(-1))
		u = (((p - 1+s) % 9 + 1 if p else 0))
		m = ((((p - 1+s) % 9 + 1 if p else 0))+(((p - 1) % 9 + 1 if p else 0)-9))
		j = (p+(((p - 1) % 9 + 1 if p else 0)-9)-1)
		z = (((j - 1) % 9 + 1 if j else 0))
		start_time = time.time()
		print('___________________',p%7,p%3,'If Zero its a PSUEDO NUMBER, SOUL EXCEPTION 7 & 3')
		
		
		print('If 3,4,5 or 6 numbers are odd to left Column for a 0 EATER, than number is Prime!')
		
		
		print(m,'|TOP|Start of Column to left')
		print(p%11,'If a 0 then number is a Psuedo Prime|Soul exception 11')
		
		print('____________________')
		print(((p)+(p-1)+(p-2))%9,'|ZONE|Either a Prime or PSUEDO for a >Z E R O<')
		print(((p)+(p+1)+(p+2))%9,'|EATER|Prime for >Z E R O< or PSUEDO NUMBERS')
		print(((((p)+ (p-2)) %19)+((((p)+ (p+2)) %19)))%18,'| If ZONE and EATER ARE ONLY ODD THAN NUMBER IS PSUEDO PERIOD!')
		
		print('________',p,'INPUTED NUMBER','____________')
		print('BOTTOM')
		print((((p)+ (p-2)) %19),'|')
		print((((p)+ (p+2)) %19),'|If Zero then input not a Twin Prime|')
		print((p%17),'|If Zero then input not a Twin Prime|LOWER PSUEDO NUMBER|Soul exception for 17')
		print((p%19),'|If Zero then input not a Twin Prime|LOWER PSUEDO NUMBER|Soul exception for 19')
		print('For a 0 ZONE IF BOTTOM contains 3 or 1 odd number AND I mean an odd at the absolute _____bottom or ___top of bottom by itself than input is Prime!')
		print('BOTTOM')
		
		
		
		e = int(time.time() - start_time)
		print('___________________________________________')
		print('{:02d}:{:02d}:{:02d}'.format(e // 3600, (e % 3600 // 60), e % 60))
ONeil is offline   Reply With Quote
Old 2020-11-26, 09:26   #19
Batalov
 
Batalov's Avatar
 
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

220558 Posts
Default

Quote:
Originally Posted by ONeil View Post
Check it out!
...NUMBER IS PSUEDO PERIOD!
...PSUEDO NUMBER
...PSUEDO NUMBER
Batalov is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
find very easy twin prime in the infamy twin primes hal1se Miscellaneous Math 13 2018-11-05 16:34
Mersenne Primes p which are in a set of twin primes is finite? carpetpool Miscellaneous Math 3 2017-08-10 13:47
Twin Primes Computer Science & Computational Number Theory 171 2013-05-14 02:57
OT: Twin Primes R.D. Silverman Math 8 2005-07-15 21:56
Twin primes again Chris Card Math 1 2005-05-26 14:18

All times are UTC. The time now is 15:23.

Thu Jan 21 15:23:07 UTC 2021 up 49 days, 11:34, 0 users, load averages: 2.48, 2.20, 2.09

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.