Skip to content

Instantly share code, notes, and snippets.

@teruteru128
Last active June 27, 2017 15:55
Show Gist options
  • Save teruteru128/ff55ace7b7af5238a1d36edd753f049e to your computer and use it in GitHub Desktop.
Save teruteru128/ff55ace7b7af5238a1d36edd753f049e to your computer and use it in GitHub Desktop.
コラッツの問題で反例かもしれない数(10進数&2進数)
10進数:22109471102059671383796642714942393631149792360856487955190294587841800871022486252652612163196360832938367608763978013876844944237576704237206902072810373921189540940520079830818715392221488557061323716817577291335634622652521928713672572731133851661298078703100656645398266940743151376817376308584222316010015960789788008597706297574848994098367499563666691266708824412889101236792179649536624320399905393881157430457991772326539937194917400795777720579028253469836556760172095629910809998314891428970428207047991475825494261234842231976086774382202391759626090080301341051584057187801927969704070634998453820923311
2進数:10101111001001000000100000001000001010010111101000110101100111100110000000001100101010101110011101001011001110110100111011011100011111001011110000111100010001010001110010111011001010111110000011111110001010010000001011111001010101110000100010100011011001001000010100010101001001111111010111110001101011011100100000110001100010010101110100100010111010000010101010101010101001100100001010110011100011111111100010111001010101011011011110110001101101110100101110110011111111101000111101111110000001110101011111101011111111110101000100110001110111111111101111000101010101010110101011111110100110000000001100010010010110010111011110010101101000111001011011111111010000111101010110011000010000100000111011101100110110111000010100111100001011110010100100000000100001001100101010110110011000000011101100111000110010011111101000111110010000110001101101011000010100001010001110110010110001001101110101100010011011011101001110000010010001110110001000100001000110010001001001010110010011010110111111001001001010110101001100011111100000101011101010101110100000101010000010010000100110001101110101001000101010001010011000000001010110010011100000111100011000110101010111110001011111100110000011001001110001101011101010011100101101100010000111100110001110100001101000111010011111101001110110100010110110110101001010000111011001011001101111101001111000000101101011110100000111100000001011100000010010000100000011111111011011000101110001100110010101101100011100110001101111110110101000011011010010011111111101000001011100010111101000110000111101111110110000011000010110100001111011100100110010100010101010011110010000000100110000110111001100110100111001111110000110101010111110100101000111000010000110011101100110001111100010111110010110100000111111111100111100111000010100000010000011011011111011011110111100010101111101101010101001000110111111111001010110111001011011101101011100010011101111000110000010011110110000101110010101000011010001010010111111000000110010001001011010111000111011000011000110100110100010111000000011011101000101110111010000110001110110101111
@teruteru128
Copy link
Author

間違ってました!
自作プログラムで偶数のときの処理と奇数のときの処理が逆になっていたようです。

@teruteru128
Copy link
Author

teruteru128 commented Jun 27, 2017

BigInteger one = BigInteger.valueOf(1L);
BigInteger three = BigInteger.valueOf(3L);
BigInteger n = new BigInteger("...", 10); // 省略
for (; n.compareTo(one) > 0;) {
  if (n.testBit(0)) { // 偶数奇数判定
    // 奇数
    n = n.shiftRight(1); // n = n.multiply(three).add(one) が正しい
  } else {
    // 偶数
    n = n.multiply(three).add(one); // n = n.shiftRight(1) が正しい
  }
}

の7行目と10行目が逆になっているせいで勘違いしたようです

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment