Skip to content

Instantly share code, notes, and snippets.

@kawasima
Last active December 28, 2017 06:45
Show Gist options
  • Save kawasima/0a3953fd4d39c9c86546 to your computer and use it in GitHub Desktop.
Save kawasima/0a3953fd4d39c9c86546 to your computer and use it in GitHub Desktop.
Coding Championships in TIS architect club

TISアーキ部にて不定期開催されるCoding Championshipsの問題集です。

コラッツの問題の最長列を求める

問題

コラッツの問題というのがあります。 http://ja.wikipedia.org/wiki/%E3%82%B3%E3%83%A9%E3%83%83%E3%83%84%E3%81%AE%E5%95%8F%E9%A1%8C

いくつか計算してみると分かりますが、なかなか1に収束しない初期値があります。

9 -> 28 -> 14 -> 7 -> 22 -> 11 -> 34 -> 17 -> 52 -> 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1

この9の例だと18ステップ必要です。

さて、2から10,000,000までの整数のうち、このステップ数が最長になるものを求めてください。

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