Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- bool pierwsza;
- int i;
- int lpowt;
- float input;
- bool lpierwsza(float p)
- {
- pierwsza = true;
- i = 2;
- lpowt = 0;
- if (fmod(p, 2) == 0 && p != 2)
- {
- return false;
- }
- else
- {
- i = 3;
- }
- while(i<=sqrt(p) && pierwsza == true)
- {
- cout << i << endl;
- cout << fmod(p,i) << endl;
- cout << "=========" << endl;
- lpowt++;
- if (fmod(p, i) == 0)
- {
- pierwsza = false;
- return false;
- }
- i= i+2;
- }
- return true;
- }
- main()
- {
- cout << "Podaj liczbe: ";
- cin >> input;
- cout << lpierwsza(input);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement