Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 1
    \$\begingroup\$ My brain hurts now. \$\endgroup\$ Commented Aug 12, 2013 at 17:55
  • 1
    \$\begingroup\$ @daniero the second solution is just for you. \$\endgroup\$ Commented Aug 13, 2013 at 8:10
  • 9
    \$\begingroup\$ (n//2,n*3+1)[n%2] is shorter. \$\endgroup\$ Commented Apr 5, 2014 at 20:34
  • 1
    \$\begingroup\$ Is this for Python2.7? I get bad operand type for unary -: 'str' in Python 3.5.1 \$\endgroup\$ Commented Dec 16, 2016 at 16:03
  • 1
    \$\begingroup\$ @Evpok wouldn't n/2 work as well as we know it is even? \$\endgroup\$ Commented Dec 16, 2016 at 16:04