Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1.         public bool czy_Pierwsza(int liczba)
  2.         {
  3.             if (liczba == 1)
  4.             {
  5.                 return false;
  6.             }
  7.             if (liczba == 2)
  8.             {
  9.                 return true;
  10.             }
  11.            if (liczba % 2 == 1)
  12.             {
  13.                 for (int i = 3; i < liczba ; i++)
  14.                 {
  15.                     if (liczba % i == 0)
  16.                     {
  17.                         return false;
  18.                     }
  19.                     return true;
  20.                 }
  21.             }
  22.             else
  23.             {
  24.                 return false;
  25.             }
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement