Skip to content

Instantly share code, notes, and snippets.

@prologic
Created April 29, 2015 01:53
Show Gist options
  • Select an option

  • Save prologic/db7667d419ce3f903745 to your computer and use it in GitHub Desktop.

Select an option

Save prologic/db7667d419ce3f903745 to your computer and use it in GitHub Desktop.
Smallest Collatz Sequence of n containing 65 primes
prologic@daisy
Wed Apr 29 11:55:09
~/tmp
$ time ./collatz.py 65 1800000
Smallest n: 1805311
Collatz Sequence: [1805311, 5415934, 2707967, 8123902, 4061951, 12185854, 6092927, 18278782, 9139391, 27418174, 13709087, 41127262, 20563631, 61690894, 30845447, 92536342, 46268171, 138804514, 69402257, 208206772, 104103386, 52051693, 156155080, 78077540, 39038770, 19519385, 58558156, 29279078, 14639539, 43918618, 21959309, 65877928, 32938964, 16469482, 8234741, 24704224, 12352112, 6176056, 3088028, 1544014, 772007, 2316022, 1158011, 3474034, 1737017, 5211052, 2605526, 1302763, 3908290, 1954145, 5862436, 2931218, 1465609, 4396828, 2198414, 1099207, 3297622, 1648811, 4946434, 2473217, 7419652, 3709826, 1854913, 5564740, 2782370, 1391185, 4173556, 2086778, 1043389, 3130168, 1565084, 782542, 391271, 1173814, 586907, 1760722, 880361, 2641084, 1320542, 660271, 1980814, 990407, 2971222, 1485611, 4456834, 2228417, 6685252, 3342626, 1671313, 5013940, 2506970, 1253485, 3760456, 1880228, 940114, 470057, 1410172, 705086, 352543, 1057630, 528815, 1586446, 793223, 2379670, 1189835, 3569506, 1784753, 5354260, 2677130, 1338565, 4015696, 2007848, 1003924, 501962, 250981, 752944, 376472, 188236, 94118, 47059, 141178, 70589, 211768, 105884, 52942, 26471, 79414, 39707, 119122, 59561, 178684, 89342, 44671, 134014, 67007, 201022, 100511, 301534, 150767, 452302, 226151, 678454, 339227, 1017682, 508841, 1526524, 763262, 381631, 1144894, 572447, 1717342, 858671, 2576014, 1288007, 3864022, 1932011, 5796034, 2898017, 8694052, 4347026, 2173513, 6520540, 3260270, 1630135, 4890406, 2445203, 7335610, 3667805, 11003416, 5501708, 2750854, 1375427, 4126282, 2063141, 6189424, 3094712, 1547356, 773678, 386839, 1160518, 580259, 1740778, 870389, 2611168, 1305584, 652792, 326396, 163198, 81599, 244798, 122399, 367198, 183599, 550798, 275399, 826198, 413099, 1239298, 619649, 1858948, 929474, 464737, 1394212, 697106, 348553, 1045660, 522830, 261415, 784246, 392123, 1176370, 588185, 1764556, 882278, 441139, 1323418, 661709, 1985128, 992564, 496282, 248141, 744424, 372212, 186106, 93053, 279160, 139580, 69790, 34895, 104686, 52343, 157030, 78515, 235546, 117773, 353320, 176660, 88330, 44165, 132496, 66248, 33124, 16562, 8281, 24844, 12422, 6211, 18634, 9317, 27952, 13976, 6988, 3494, 1747, 5242, 2621, 7864, 3932, 1966, 983, 2950, 1475, 4426, 2213, 6640, 3320, 1660, 830, 415, 1246, 623, 1870, 935, 2806, 1403, 4210, 2105, 6316, 3158, 1579, 4738, 2369, 7108, 3554, 1777, 5332, 2666, 1333, 4000, 2000, 1000, 500, 250, 125, 376, 188, 94, 47, 142, 71, 214, 107, 322, 161, 484, 242, 121, 364, 182, 91, 274, 137, 412, 206, 103, 310, 155, 466, 233, 700, 350, 175, 526, 263, 790, 395, 1186, 593, 1780, 890, 445, 1336, 668, 334, 167, 502, 251, 754, 377, 1132, 566, 283, 850, 425, 1276, 638, 319, 958, 479, 1438, 719, 2158, 1079, 3238, 1619, 4858, 2429, 7288, 3644, 1822, 911, 2734, 1367, 4102, 2051, 6154, 3077, 9232, 4616, 2308, 1154, 577, 1732, 866, 433, 1300, 650, 325, 976, 488, 244, 122, 61, 184, 92, 46, 23, 70, 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1]
No. of primes: 67
real 0m2.979s
user 0m2.970s
sys 0m0.011s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment