CyberN00b

Untitled

Jan 16th, 2022 (edited)
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2.  
  3. class Program {
  4.     static int fun(int a) {
  5.         int i = 2;
  6.         while (i <= Math.Sqrt(a) && a % i != 0)
  7.         {
  8.             i += 1;
  9.         }
  10.         return Convert.ToInt32(i > Math.Sqrt(a));
  11.     }
  12.     static void Main(string[] args) {
  13.         Console.Write("Введите первое число: ");
  14.         int A = Convert.ToInt32(Console.ReadLine());
  15.         Console.Write("Введите второе число: ");
  16.         int B = Convert.ToInt32(Console.ReadLine());
  17.         Console.Write("Введите третье число: ");
  18.         int C = Convert.ToInt32(Console.ReadLine());
  19.         int ANSWER = fun(A) + fun(B) + fun(C);
  20.         Console.WriteLine($"Всего {ANSWER} простых числа");
  21.     }
  22. }
Add Comment
Please, Sign In to add comment