▲ | tomtomtom777 a day ago | |||||||
Fascinating. It can see it work but I still can't really wrap my head around where the magic cycle length of 4 comes from. | ||||||||
▲ | danbruc a day ago | parent | next [-] | |||||||
Combining two consecutive integers starting with an even one yields one.
If we start at a number divisible by four and do this twice, we get one twice.
And combining the two of course yields zero and we are right back at the start. | ||||||||
▲ | betasilly a day ago | parent | prev | next [-] | |||||||
Another interesting fact is that each time you make the xor of four consecutive numbers, beginning with an even number, the result is zero. Example in J.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Summing a hundred millions: +/ f"0 ] 2 * i 100000000 gives zero (it takes a few seconds). So it seems the stated property holds for every even n. | ||||||||
| ||||||||
▲ | NickPollard a day ago | parent | prev | next [-] | |||||||
There are essentially two bits of information in the 'state' of this iterated algorithm: a) Are all the non-lowest bits zero, or are they the value of the latest N b) the value of the lowest bit So the cycle of (N, 1, N+3, 0) corresponds to (A) and (B) being: (0,0), (0,1), (1,1), (1, 0) - i.e. the 4 possible combinations of these states. | ||||||||
▲ | HappyPanacea a day ago | parent | prev | next [-] | |||||||
If we generalize the problem to base k (they are k-1 duplicate of each number except the missing number, find missing one using base k-wise addition) then we can see the cycle is the smallest number such the base k-wise addition from 1 to the number is zero and it is power of k will form a cycle. I'm not sure if all such numbers are power of k if they exists or if there is an upper bound on them. For example in base 4 there appears to be no such cycle. | ||||||||
| ||||||||
▲ | a day ago | parent | prev [-] | |||||||
[deleted] |