Advertisement
Guest User

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

a guest
Jul 21st, 2010
107
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
Advertisement
RAW Paste Data Copied
Advertisement