CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
A Voodoo prime is a prime number whose reciprocal (in decimal) has the same number in its digits. For example, 7 is a voodoo prime because its reciprocal 1/7=0.14285714285 contains 7.
*/
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
bool isPrime(int n){
for(int i=2; i<n; i++){
if(!(n%i)) return false;
}
return true;
}
template <typename T>
string to_string_with_precision(const T a_value, const int n = 6)
{
ostringstream out;
out.precision(n);
out << std::fixed << a_value;
return out.str();
}
int main() {
string strInput;
cout << "Enter upper limit of a range:" << endl;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run