Advertisement
Spocoman

04. Refactoring: Prime Checker

Jan 19th, 2022
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2.  
  3. namespace primeChecker
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int number = int.Parse(Console.ReadLine());
  10.            
  11.             for (int current = 2; current <= number; current++)
  12.             {
  13.                 string isSimple = "true";
  14.                 for (int divisor = 2; divisor < current; divisor++)
  15.                 {
  16.                     if (current % divisor == 0)
  17.                     {
  18.                         isSimple = "false";
  19.                         break;
  20.                     }
  21.                 }
  22.                 Console.WriteLine($"{current} -> {isSimple}");
  23.             }
  24.         }
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement