login
A318759
Numbers x whose trajectory reaches 1 under recursive applications of the map x -> x/3 if x == 0 (mod 3), x -> (4*x+2)/3 if x == 1 (mod 3), x -> (4*x+1)/3 if x == 2 (mod 3).
0
1, 2, 3, 4, 6, 9, 12, 13, 18, 20, 27, 29, 36, 39, 40, 54, 60, 65, 81, 87, 108, 109, 117, 120, 121, 136, 146, 162, 180, 182, 195, 197, 243, 245, 261, 263, 272, 324, 327, 328, 332, 351, 360, 363
OFFSET
1,2
PROG
(C++)
#include <iostream>
using namespace std;
void Number_Generator();
int main()
{
Number_Generator();
return 0;
}
void Number_Generator()
{
int Number_Tested=1; int Temporary;
int Divideby=3;
//For numbers bigger than this you need to use unsigned long int or do some large number implementation.
int Limit=38000;
while(Number_Tested<Limit)
{
Temporary=Number_Tested;
//There are two cycles. 1 and 7 are the smallest numbers in those cycles.
while((Temporary!=1) && (Temporary!=7))
{
if(Temporary%Divideby)
Temporary=(Temporary*(Divideby+1)+(Divideby-(Temporary%Divideby)))/Divideby;
else
Temporary=Temporary/Divideby;
}
if(Temporary==1)
cout<<Number_Tested<<"\n";
Number_Tested++;
}
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Jack Warren, Sep 02 2018
STATUS
approved