1到10的阶乘;200以内的素数

using System;
namespace JieCheng
{
    
    
  class Program
  {
    
    
    static void Main(string[] args)`
    {
      int b = 1;
    int c = 0;
    for(int a = 1;a <= 10;a++)
      {
    
    
        b *= a;
        c += b;
     }
    Console.WriteLine(c);
    Console.ReadKey();`
    }
  }
}

using System;
namespace SuShu
{
    
    
  class Program
  {
    
    
    static void Main(string[] args)
    {
    
    

        for(int a = 2;a <= 200;a ++)
       {
    
    
           int b = 0;
               for(int c = 2;c < a;c ++)
              {
    
    
                   if (a % c == 0)
                  {
    
    
                      b = b + 1;
                  }
             }
         if(b == 0)
           {
    
    
            Console.WriteLine("{0}是素数",a);
           }
         else
           {
    
    
            Console.WriteLine("{0}不是素数",a);
           }
Console.ReadKey();
    }
  }
}

猜你喜欢

转载自blog.csdn.net/qq_52034378/article/details/109569547