Foibs

Prime Number

Nov 12th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string doseArithmo;
  10.             int arithmos;
  11.             Arxh:
  12.             int count = 0;
  13.  
  14.             Console.WriteLine("Dose enan arithmo");
  15.             doseArithmo = Console.ReadLine();
  16.             arithmos = int.Parse(doseArithmo);
  17.  
  18.             for (int i = 2; i < arithmos; i++)
  19.             {
  20.                 if (arithmos % i == 0)
  21.                 {
  22.                     count = count + 1;
  23.                 }
  24.             }
  25.  
  26.             if (count < 1)
  27.             {
  28.                 Console.WriteLine("O arithmos {0} einai protos", arithmos);
  29.             }
  30.             else
  31.             {
  32.                 Console.WriteLine("O arithmos {0} den einai protos", arithmos);
  33.             }
  34.  
  35.  
  36.             goto Arxh;
  37.         }
  38.     }
  39. }
Add Comment
Please, Sign In to add comment