Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- #include <random>
- #include <algorithm>
- #include <math.h>
- #include <string>
- #include <sstream>
- using namespace std;
- int isPalindrom(int a);
- int count(int a, int b) {
- int count = 0;
- bool prime;
- for (int i = a; i <= b; i++) {
- prime = true;
- double sqrti = sqrt((double)i);
- for (int j = 2; j < sqrti + 1; j++)
- if (i % j == 0) {
- prime = false;
- break;
- }
- if (prime)
- count++;
- count += isPalindrom(i);
- }
- return count;
- }
- int isPalindrom(int a) {
- int b;
- stringstream ss;
- b = a;
- while (b > 0)
- {
- ss << b % 10;
- b /= 10;
- }
- ss >> b;
- if (a == b)
- return 1;
- else
- return 0;
- }
- int getReverse(int n) {
- int r = n % 10;
- while (n /= 10) {
- r = r * 10 + n % 10;
- }
- return r;
- }
- int main() {
- int a = 0, b = 0;
- cin >> a >> b;
- cout << "count = " << count(a, b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment