求素数的练习

来源:互联网 发布:淘宝倒闭是必然 编辑:程序博客网 时间:2024/05/16 14:16
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 素数{    class Program    {        static void Main(string[] args)        {            for (int i = 101; i < 200; i++)            {                if (!isPrimeNum(i))                {                    Console.WriteLine("素数:"+i.ToString());                }            }            Console.WriteLine("结束");            Console.ReadKey();        }        private static bool isPrimeNum(int i)        {            for (int j = 2; j < i-1; j++)            {                if (i%j==0)                {                    return true;                }            }            return false;        }    }}

0 0
原创粉丝点击