偶数 素数

来源:互联网 发布:java 线程池 executor 编辑:程序博客网 时间:2024/05/01 00:41
using System;
using System.Collections.Generic;
using System.Text;
namespace 素数
{
    class Program
    {
        static void Main(string[] args)
        {
            for (; ; )
            {
                Console.WriteLine("请随意输入一个大于7的数字:");
                string s = Console.ReadLine();
                int Num = int.Parse(s);
                Console.WriteLine("判断是不是素数,结果为:"+Second_True(Num));
                Console.WriteLine("判断是不是偶数,结果为:"+OUSHU(Num));
            } 
           
        }
     

        public static bool Second_True(int m)
        {
            bool yes = false;
            int j = 2;

            for (; j <= Math.Sqrt(m); j++)
            {
                if (m % j == 0)
                {
                    return yes;
                }
            }
            return yes = true;
        }
        public static bool OUSHU(int m)
        {
            bool yes = false;
          
                for (int i = 0; i <= m; i++)
                {
                    if (i % 2 == 0 && i > 6)
                    {
                        //Console.WriteLine(i);
                        yes = true;
                    }
                   
                }
                return yes;
 
        }
    }
}