Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<math.h>
- using namespace std;
- int main() {
- int a, b, s = 0, r, k, suma = 0;
- float d;
- cout << "Podaj zakres:" << endl;
- cin >> a >> b;
- for(int i = a; i <= b; i++) {
- int w = i;
- suma = 0;
- do{
- k = w % 10;
- suma += k;
- w -= k;
- w /= 10;
- } while (w != 0);
- if(suma!=1){
- s = 0;
- d = sqrt(suma);
- for (int j = 2; j <= d; j++) {
- r = suma%j;
- if (r == 0) {
- s++;
- }
- }
- if (s == 0) {
- cout << i<<"->";
- }
- }
- }
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement