Advertisement
EndymionSpr

LiczbaPierwsza5

Oct 18th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 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 SumaCyfr
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             /*  string str = Console.ReadLine();
  15.               int a = int.Parse(str);
  16.  
  17.               for (int i = a - 1; i > 1; i--)
  18.               {
  19.                   if (a % i == 0) { Console.WriteLine("Liczba podzielna przez: " + i); goto A; }
  20.  
  21.               }
  22.               Console.WriteLine("Liczba pierwsza!");
  23.               A:
  24.  
  25.               Console.ReadKey(); */
  26.  
  27.             string str = Console.ReadLine();
  28.             int a = int.Parse(str);
  29.  
  30.             for (int i = a - 1; i > 1; i--)
  31.             {
  32.                 if (a % i == 0) { Console.WriteLine("Liczba podzielna przez: " + i); break; }
  33.                 if (i == 2) Console.WriteLine("Liczba pierwsza!");
  34.             }
  35.             Console.ReadKey();
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement