![]() |
![]() |
#12 | |
Feb 2017
Nowhere
13×17×19 Posts |
![]() Quote:
![]() A generally descriptive word for "intended to cause delay or waste time" is "dilatory." |
|
![]() |
![]() |
![]() |
#13 |
"Ed Hall"
Dec 2009
Adirondack Mtns
2·32·197 Posts |
![]() |
![]() |
![]() |
![]() |
#14 | |
Feb 2017
Nowhere
101478 Posts |
![]() Quote:
![]() 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.) |
|
![]() |
![]() |
![]() |
#15 |
"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. |
![]() |
![]() |
![]() |
#16 |
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 |
![]() |
![]() |
![]() |
#17 |
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!
|
![]() |
![]() |
![]() |
#18 |
Dec 2017
111100002 Posts |
![]()
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)) |
![]() |
![]() |
![]() |
#19 |
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2
2·4,637 Posts |
![]() |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
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 |