Collatz Problem by croyal

System.in.withReader{
   n=Integer.parseInt(it.readLine())
   println n
   while(n!=1){
      if(n%2==1){
         n=3*n+1
      } else {
         n=(int)(n/2)
      }
      println n
   }
}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page