mersenneforum.org A stab at Twin Primes, Pour on the Steak Sauce
 Register FAQ Search Today's Posts Mark Forums Read

2020-11-13, 17:16   #12
Dr Sardonicus

Feb 2017
Nowhere

13×17×19 Posts

Quote:
 Originally Posted by retina 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."

2020-11-13, 17:23   #13
EdH

"Ed Hall"
Dec 2009

2·32·197 Posts

Quote:
 Originally Posted by retina 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. . .

2020-11-13, 21:43   #14
Dr Sardonicus

Feb 2017
Nowhere

101478 Posts

Quote:
 Originally Posted by EdH 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.)

 2020-11-14, 14:34 #15 EdH     "Ed Hall" Dec 2009 Adirondack Mtns 2×32×197 Posts 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.
 2020-11-14, 14:59 #16 Dr Sardonicus     Feb 2017 Nowhere 13×17×19 Posts 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
 2020-11-14, 15:00 #17 mathwiz   Mar 2019 100011112 Posts 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!
 2020-11-26, 07:43 #18 ONeil   Dec 2017 111100002 Posts 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))
2020-11-26, 09:26   #19
Batalov

"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

2·4,637 Posts

Quote:
 Originally Posted by ONeil Check it out! ...NUMBER IS PSUEDO PERIOD! ...PSUEDO NUMBER ...PSUEDO NUMBER

 Similar Threads Thread Thread Starter Forum Replies Last Post hal1se Miscellaneous Math 13 2018-11-05 16:34 carpetpool Miscellaneous Math 3 2017-08-10 13:47 Computer Science & Computational Number Theory 171 2013-05-14 02:57 R.D. Silverman Math 8 2005-07-15 21:56 Chris Card Math 1 2005-05-26 14:18

All times are UTC. The time now is 16:30.

Thu Jan 28 16:30:18 UTC 2021 up 56 days, 12:41, 0 users, load averages: 4.42, 4.78, 4.67