Advertisement
Guest User

ForC#1

a guest
Feb 28th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int a = Convert.ToInt32(Console.ReadLine());
  15.             int b = Convert.ToInt32(Console.ReadLine());
  16.  
  17.             Console.WriteLine(Func(a, b));
  18.  
  19.             if(Func(a, b) == 1)
  20.             {
  21.                 Console.WriteLine("Простое!");
  22.             }
  23.             else
  24.             {
  25.                 Console.WriteLine("Не простое!!");
  26.             }
  27.  
  28.             Console.ReadKey();
  29.         }
  30.  
  31.         public static int Func(int k, int n)
  32.         {
  33.             if( k * k > n)
  34.             {
  35.                 return 1;
  36.             }
  37.             if(n % k == 0)
  38.             {
  39.                 return 0;
  40.             }
  41.  
  42.             return Func(n, k++);
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement