Check out the Pastebin Gadgets Shop. We have thousands of fun, geeky & affordable gadgets on sale :-)Want more features on Pastebin? Sign Up, it's FREE!
tweet

# A052213 Numbers n with prime signature(n) = prime signature(n+1)

By: a guest on Jul 21st, 2010  |  syntax: None  |  size: 1.00 KB  |  views: 41  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1. #include <iostream>
2. #include <vector>
3. #include <algorithm>
4.
5. using namespace std;
6.
7. template<class T>
8. string str( const vector<T>& v )
9. {
10.    stringstream ss;
11.    for ( int i = 0; i < (int)v.size(); i++ )
12.       ss << (i?",":"") << v[i];
13.    return "{" + ss.str() + "}";
14. }
15.
16. void getPrimeFactorsSig( __int64 x, vector<int>& v )
17. {
18.    v.clear();
19.    for ( __int64 i = 2; i*i <= x; i++ )
20.    {
21.       int power = 0;
22.       while ( x % i == 0 )
23.          x /= i, ++power;
24.       if ( power )
25.          v.push_back( power );
26.    }
27.    if ( x != 1 )
28.       v.push_back( 1 );
29.    sort( v.begin(), v.end() );
30. }
31. vector<int> getPrimeFactorsSig( __int64 x )
32. {
33.    vector<int> v;
34.    getPrimeFactorsSig( x, v );
35.    return v;
36. }
37.
38. void main()
39. {
40.    __int64 K = 1000000000LL;
41.    for ( __int64 i = K + 0; i < K + 4000; i++ )
42.    {
43.       vector<int> a = getPrimeFactorsSig( i );
44.       vector<int> b = getPrimeFactorsSig( i+1 );
45.       if ( a == b )
46.       {
47.          cout << i << " " << str(a) << endl;
48.       }
49.    }
50. }
clone this paste RAW Paste Data
Top