c#:角谷猜想

  1. using System;

  2. class Jiaogu 

  3. {

  4.     public static void Main(string[] args) 

  5.     {

  6.         forint n=1; n<=100; n++ )

  7.         {

  8.             int a = n;

  9.             while( a != 1 )

  10.             {

  11.                 Console.Write( " " +a );

  12.                 if( a%2==1 ) a = a*3+1; else a /= 2;

  13.             }

  14.             Console.WriteLine(" " +a);

  15.         }

  16.     }

  17. }

posted @ 2019-07-25 16:11  MichaelCecil  阅读(592)  评论(0编辑  收藏  举报