求1-100以內所有的質數

 for (int i = 2; i <= 100; i++)
        {
            bool s = false;
            for (int j = 2; j <= i / 2 + 1; j++)
            {
                if (i % j == 0)
                {
                     s = true;
                     break;
                }
              

            }
            if (!s)
            {
               
                this.Label1.Text += i.ToString() + ",</br>";
            }
        }

posted @ 2006-11-28 14:53  Nina  阅读(1506)  评论(1编辑  收藏  举报