# Pi Cycle

When I was playing around with some P3 systems, I stumbled on an unexpected cycle involving pi. The idea is to start with any 3-digit number (incuding numbers starting with 0s) and divide it by pi, then take the first three digits after the decimal point as your new input. If you start with almost any number (except 000, 104, 208, 312, and 416) you eventually end up in a cycle:

445, 647, 946, 121, 515, 929, 709, 681, 769, 780, 281, 445,...

To work it out in full:

445/pi = 141.647...
647/pi = 205.946...
946/pi = 301.121...
121/pi = 38.515...
515/pi = 163.929...
929/pi = 295.709...
709/pi = 225.681...
681/pi = 216.769...
769/pi = 244.780...
780/pi = 248.281...
281/pi = 89.445...

If you start with any of the five exception numbers, the first three digits are the same as the number itself. There could be other patterns if you change pi to something else, like the golden mean or e.

It's not the most interesting mathematical discovery, but it was pretty surprising to me. Just wanted to share it.

I tried it with e = 2.718281828459 and I found five cycles

• 188, 161, 228, 876, 262, 384, 265, 488, 525, 136, 031, 404, 623,...

540, 654, 593, 152, 917, 345, 918, 713, 298, 628, 028, 300, 363,...

223, 037, 611, 774, 738, 495, 100, 787, 521, 665, 639, 074,...

173, 643, 546, 862, 112, 202, 311, 410, 830, 339, 711, 562, 748,...

146, 710, 194, 368, 379, 426, 716, 401, 519, 929, 760, 588, 313,...

If you start with 000 or 785 it repeats only itself. The cycles are pretty neat because they look like random sequences but have a simple underlying pattern. Cool find.

If you change the constant to natural logarithm of 2 instead of pi, and multiply instead of divide, you can get a cycle that passes over 125 Pick 3 combos:

852, 561, 855, 640, 614, 592, 343, 749, 167, 755, 326, 965, 887, 821, 073, 599,
195, 163, 982, 670, 408, 804, 290, 012, 317, 727, 918, 309, 182, 152, 358, 146,
199, 936, 785, 120, 177, 687, 192, 084, 224, 264, 990, 215, 026, 021, 556, 389,
634, 455, 381, 089, 690, 271, 842, 629, 989, 522, 822, 766, 950, 489, 948, 103,
394, 099, 621, 444, 757, 712, 520, 436, 212, 947, 410, 190, 697, 123, 257, 138,
654, 318, 420, 121, 870, 038, 339, 976, 511, 198, 243, 434, 825, 846, 402, 645,
079, 758, 405, 724, 838, 857, 027, 714, 907, 684, 112, 632, 609, 827, 232, 810,
449, 223, 571, 787, 506, 732, 383, 475, 244, 127, 029, 101, 007,...

Thanks for checking out the topic. I was testing different multiplyer and divider numbers to see if I could find one that generated a giant cycle using at least half the combos. That one you found is pretty big, I never could find one as big. I didn't think to test logarithm numbers. It looks like there's no rime or reason to the number of cycles or how big they get. I may put a pin in this investigation for now.

I've been lazily doing it by hand with a calculator, but I assume you ran a script to generate them fast. Do you mind sharing it?

Sure, I put it here: https://repl.it/repls/VerifiableIroncladLanguage

(I don't control the random words in the URL)

It's not optimized, so if you tweak it to run for Pick 4 or Quinto it will run pretty slow, I think it's O(n^2) in its current form. But 1000 is small enough to give all the cycles in 1 second or less. Do you still play Pick 2? If you're trying to find a long cycle with this method, you'll have more luck with a shorter digit string. You don't even have to use irrational numbers.

Thanks.

Can we use this with pick 3 or 4?