<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mediawiki.zeropage.org/index.php?action=history&amp;feed=atom&amp;title=3N%2B1Problem%2F1002</id>
	<title>3N+1Problem/1002 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mediawiki.zeropage.org/index.php?action=history&amp;feed=atom&amp;title=3N%2B1Problem%2F1002"/>
	<link rel="alternate" type="text/html" href="https://mediawiki.zeropage.org/index.php?title=3N%2B1Problem/1002&amp;action=history"/>
	<updated>2026-05-15T09:46:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://mediawiki.zeropage.org/index.php?title=3N%2B1Problem/1002&amp;diff=26778&amp;oldid=prev</id>
		<title>imported&gt;Unknown at 05:22, 7 February 2021</title>
		<link rel="alternate" type="text/html" href="https://mediawiki.zeropage.org/index.php?title=3N%2B1Problem/1002&amp;diff=26778&amp;oldid=prev"/>
		<updated>2021-02-07T05:22:16Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== 접근 ===&lt;br /&gt;
일단 문제를 보니 그냥 카운트를 하면 될 것 같아서 바로 코딩. 3번째 값도 그냥 별다른 어려움없이 바로 코드.&lt;br /&gt;
 def countCode(n):&lt;br /&gt;
     count = 1&lt;br /&gt;
     while n != 1:&lt;br /&gt;
         if n % 2 == 1: n=n*3 + 1&lt;br /&gt;
         else: n = n/2&lt;br /&gt;
         count += 1&lt;br /&gt;
     return count&lt;br /&gt;
 &lt;br /&gt;
 def cycleLengthMax(i,j):&lt;br /&gt;
     return max([countCode(each) for each in range(i,j+1)])&lt;br /&gt;
 &lt;br /&gt;
 def cycleLengthMax2(i,j):&lt;br /&gt;
     print [(each,countCode(each)) for each in range(i,j+1)]&lt;br /&gt;
 &lt;br /&gt;
 def cycleLengths(i,j):&lt;br /&gt;
     result = [countCode(each) for each in range(i,j+1)]&lt;br /&gt;
     result.sort()&lt;br /&gt;
     return result&lt;br /&gt;
 &lt;br /&gt;
 def main():&lt;br /&gt;
     print countCode(22)&lt;br /&gt;
     print cycleLengthMax(1,10)&lt;br /&gt;
     print cycleLengthMax(100,200)&lt;br /&gt;
     print cycleLengthMax(201,210)&lt;br /&gt;
     print cycleLengthMax(900,1000)&lt;br /&gt;
     print cycleLengthMax(1,1000000)&lt;br /&gt;
 &lt;br /&gt;
 def main2():&lt;br /&gt;
     print countCode(22)&lt;br /&gt;
     print cycleLengths(1,10)[-3]&lt;br /&gt;
     print cycleLengths(100,200)[-3]&lt;br /&gt;
 &lt;br /&gt;
 def main3():&lt;br /&gt;
     for i in range(1,30):&lt;br /&gt;
         cycleLengthMax2(1,i)&lt;br /&gt;
 &lt;br /&gt;
 if __name__==&amp;quot;__main__&amp;quot;:&lt;br /&gt;
     import psyco&lt;br /&gt;
     psyco.full()&lt;br /&gt;
     #main()&lt;br /&gt;
     #main2()&lt;br /&gt;
     main3()&lt;br /&gt;
&lt;/div&gt;</summary>
		<author><name>imported&gt;Unknown</name></author>
	</entry>
</feed>