Facebook
From Emerald Dove, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 264
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int p=1,d,licz=0,l,o,n,pierwsza,zlozona;
  8.     cout << "Sprawdzanie czy liczba jest pierwsza!" << endl;
  9.     cout << "Podaj liczbe"<<endl;
  10.     cin >>l;
  11.     for (o=2;o<l;o++)
  12.     {
  13.  
  14.     if (l!=1&&l!=2)
  15.     {
  16.        for (d=2;d<=sqrt(l);d++)
  17.     {
  18.         if (l%d==0)
  19.  
  20.     {
  21.         p=0;
  22.     }
  23.     }
  24.  
  25.     }
  26.  
  27.     if (p==0) n=zlozona;
  28.     else n=pierwsza;
  29.     if (n==pierwsza) cout <<"2"<<endl;
  30.     }
  31.  
  32.     return 0;
  33. }
  34.  

Replies to Untitled rss

Title Name Language When
Re: Untitled Subtle Plover text 5 Years ago.