corproblem[n_] := If[EvenQ[n], n/2, 3 n + 1];
NestList[corproblem, 156, 36]
dcs[x_]:=Apply[Plus,(IntegerDigits[x])^3];
findloopdcs[n_]:=
Block[{m=n,u,dat},dat={m};m=dcs[m];
While[!MemberQ[dat,m],dat=Append[dat,m];m=dcs[m]];
dat=Append[dat,m];
u=Flatten[Position[dat,Last[dat]]];{n,u[[1]]-1,Last[dat],
u[[2]]-u[[1]]}];
loopdata
=Union[Table[{findloopdcs[n][[3]],findloopdcs[n][[4]]},
{n,1,2917}]];
Table[NestList[dcs,loopdata[[k,1]],loopdata[[k,2]]-1],
{k,1,Length[loopdata]}]
dsf[n_]:=Block[{m=n,t},t=IntegerDigits[m];
findloop[n_]:=Block[{m=n,u,dat},dat={m};m=dsf[m];
While[!MemberQ[dat,m],
dat=Append[dat,m];m=dsf[m]];
dat=Append[dat,m];
u=Flatten[Position[dat,Last[dat]]];
{n,u[[1]]-1,Last[dat],u[[2]]-u[[1]]}];
loop1A = {1};
loop1B = {3435};
loop2 = {421845123,16780890};
loop3 = {16777500,2520413,3418};
loop8 = {809265896,808491852,437755524,1657004,873583,
34381154,16780909,792488396};
loop11 = {791621579,776537851,19300779,776488094,422669176,
388384265,50381743,17604196,388337603,34424740,824599};
loop40 = {793312220,388244100,33554978,405027808,34381363,
16824237,17647707,3341086,16824184,33601606,140025,3388,
33554486,16830688,50424989,791621836,405114593,387427281,
35201810,16780376,18517643,17650825,17653671,1743552,
830081,33554462,53476,873607,18470986,421845378,34381644,
16824695,404294403,387421546,17651084,17650799,776537847,
20121452,3396,387467199};
loop97 = {1583236420,16827317,18470991,792441996,1163132183,
16823961,404291050,387424134,17601586,17697199,1163955211,
387473430,18424896,421022094,387421016,17647705,2520668,
16873662,17740759,389894501,808398820,454529386,404251154,
7025,826673,17694102,388290951,808398568,454579162,388297455,
421805001,16780606,17740730,2470915,388247419,421799008,
792442000,388244555,33564350,53244,3668,16870555,17656792,
389164017,405068190,404247746,1694771,389114489,808395951,
808401689,437799052,776491477,390761830,405067961,388340728,
51155506,59159,774847229,406668854,33698038,421021659,
387470537,19251281,404200841,16777992,777358268,36074873,
18471269,405068166,16920568,404294148,404198735,405024914,
387424389,421799034,775665066,1839961,791664879,793358849,
809222388,437752177,3297585,405027529,388250548,50338186,
33604269,387514116,17650826,17697202,389114241,404198251,
404201349,387421291,405021541,6770,1693743,388290999};
elementsofloop =
Join[loop1A,loop1B,loop2,loop3,loop8,loop11,loop40,loop97];
gc[n_] := Block[{m = n,u,dat},dat = {m}; m = dsf[m];
While[! MemberQ[dat,m],dat = Append[dat,m]; m = dsf[m]];
dat = Append[dat,m]; Last[dat]];
lookforloop[s_]:=Block[{firststep,p,n,data,u=s},
Do[
Do[firststep[p]=Union[Table[Nest[dsf,n,5],
{n,500000m+10000p+1,500000m+10000p+10000}]],{p,0,49}];
data[m]=Map[gc,Union[Flatten[Table[firststep[t],
{t,0,49}]]]],
{m,5s,5s+4}];
ddata[s]=Union[Flatten[Table[data[m],{m,5s,5s+4}]]];
Complement[ddata[s],elementsofloop]];
Do[star=40nn;
Do[
Do[
Clear[ddata];Print[st];Print[lookforloop[st]],
{st,5kk+1,5kk+5}];Print[kk],{kk,star,star+10}];
Do[
Do[
Clear[ddata];Print[st];Print[lookforloop[st]],
{st,5kk+1,5kk+5}];Print[kk],{kk,star+11,star+20}];
Do[
Do[
Clear[ddata];Print[st];Print[lookforloop[st]],
{st,5kk+1,5kk+5}];Print[kk],{kk,star+21,star+30}];
Do[
Do[
Clear[ddata];Print[st];Print[lookforloop[st]],
{st,5kk+1,5kk+5}];Print[kk],{kk,star+31,star+40}],{nn,0,6}]
#include <iostream>
#include <map>
#include <vector>
void initMap(std::map<long, char>& answer) {
answer.insert(std::map<long, char>::value_type(1, 'a'));
answer.insert(std::map<long, char>::value_type(3435, 'b'));
answer.insert(std::map<long, char>::value_type(421845123, 'c'));
answer.insert(std::map<long, char>::value_type(16780890, 'c'));
answer.insert(std::map<long, char>::value_type(16777500, 'd'));
answer.insert(std::map<long, char>::value_type(2520413, 'd'));
answer.insert(std::map<long, char>::value_type(3418, 'd'));
answer.insert(std::map<long, char>::value_type(809265896, 'e'));
answer.insert(std::map<long, char>::value_type(808491852, 'e'));
answer.insert(std::map<long, char>::value_type(437755524, 'e'));
answer.insert(std::map<long, char>::value_type(1657004, 'e'));
answer.insert(std::map<long, char>::value_type(873583, 'e'));
answer.insert(std::map<long, char>::value_type(34381154, 'e'));
answer.insert(std::map<long, char>::value_type(16780909, 'e'));
answer.insert(std::map<long, char>::value_type(792488396, 'e'));
answer.insert(std::map<long, char>::value_type(791621579, 'f'));
answer.insert(std::map<long, char>::value_type(776537851, 'f'));
answer.insert(std::map<long, char>::value_type(19300779, 'f'));
answer.insert(std::map<long, char>::value_type(776488094, 'f'));
answer.insert(std::map<long, char>::value_type(422669176, 'f'));
answer.insert(std::map<long, char>::value_type(388384265, 'f'));
answer.insert(std::map<long, char>::value_type(50381743, 'f'));
answer.insert(std::map<long, char>::value_type(17604196, 'f'));
answer.insert(std::map<long, char>::value_type(388337603, 'f'));
answer.insert(std::map<long, char>::value_type(34424740, 'f'));
answer.insert(std::map<long, char>::value_type(824599, 'f'));
answer.insert(std::map<long, char>::value_type(793312220, 'g'));
answer.insert(std::map<long, char>::value_type(388244100, 'g'));
answer.insert(std::map<long, char>::value_type(33554978, 'g'));
answer.insert(std::map<long, char>::value_type(405027808, 'g'));
answer.insert(std::map<long, char>::value_type(34381363, 'g'));
answer.insert(std::map<long, char>::value_type(16824237, 'g'));
answer.insert(std::map<long, char>::value_type(17647707, 'g'));
answer.insert(std::map<long, char>::value_type(3341086, 'g'));
answer.insert(std::map<long, char>::value_type(16824184, 'g'));
answer.insert(std::map<long, char>::value_type(33601606, 'g'));
answer.insert(std::map<long, char>::value_type(140025, 'g'));
answer.insert(std::map<long, char>::value_type(3388, 'g'));
answer.insert(std::map<long, char>::value_type(33554486, 'g'));
answer.insert(std::map<long, char>::value_type(16830688, 'g'));
answer.insert(std::map<long, char>::value_type(50424989, 'g'));
answer.insert(std::map<long, char>::value_type(791621836, 'g'));
answer.insert(std::map<long, char>::value_type(405114593, 'g'));
answer.insert(std::map<long, char>::value_type(387427281, 'g'));
answer.insert(std::map<long, char>::value_type(35201810, 'g'));
answer.insert(std::map<long, char>::value_type(16780376, 'g'));
answer.insert(std::map<long, char>::value_type(18517643, 'g'));
answer.insert(std::map<long, char>::value_type(17650825, 'g'));
answer.insert(std::map<long, char>::value_type(17653671, 'g'));
answer.insert(std::map<long, char>::value_type(1743552, 'g'));
answer.insert(std::map<long, char>::value_type(830081, 'g'));
answer.insert(std::map<long, char>::value_type(33554462, 'g'));
answer.insert(std::map<long, char>::value_type(53476, 'g'));
answer.insert(std::map<long, char>::value_type(873607, 'g'));
answer.insert(std::map<long, char>::value_type(18470986, 'g'));
answer.insert(std::map<long, char>::value_type(421845378, 'g'));
answer.insert(std::map<long, char>::value_type(34381644, 'g'));
answer.insert(std::map<long, char>::value_type(16824695, 'g'));
answer.insert(std::map<long, char>::value_type(404294403, 'g'));
answer.insert(std::map<long, char>::value_type(387421546, 'g'));
answer.insert(std::map<long, char>::value_type(17651084, 'g'));
answer.insert(std::map<long, char>::value_type(17650799, 'g'));
answer.insert(std::map<long, char>::value_type(776537847, 'g'));
answer.insert(std::map<long, char>::value_type(20121452, 'g'));
answer.insert(std::map<long, char>::value_type(3396, 'g'));
answer.insert(std::map<long, char>::value_type(387467199, 'g'));
answer.insert(std::map<long, char>::value_type(1583236420, 'h'));
answer.insert(std::map<long, char>::value_type(16827317, 'h'));
answer.insert(std::map<long, char>::value_type(18470991, 'h'));
answer.insert(std::map<long, char>::value_type(792441996, 'h'));
answer.insert(std::map<long, char>::value_type(1163132183, 'h'));
answer.insert(std::map<long, char>::value_type(16823961, 'h'));
answer.insert(std::map<long, char>::value_type(404291050, 'h'));
answer.insert(std::map<long, char>::value_type(387424134, 'h'));
answer.insert(std::map<long, char>::value_type(17601586, 'h'));
answer.insert(std::map<long, char>::value_type(17697199, 'h'));
answer.insert(std::map<long, char>::value_type(1163955211, 'h'));
answer.insert(std::map<long, char>::value_type(387473430, 'h'));
answer.insert(std::map<long, char>::value_type(18424896, 'h'));
answer.insert(std::map<long, char>::value_type(421022094, 'h'));
answer.insert(std::map<long, char>::value_type(387421016, 'h'));
answer.insert(std::map<long, char>::value_type(17647705, 'h'));
answer.insert(std::map<long, char>::value_type(2520668, 'h'));
answer.insert(std::map<long, char>::value_type(16873662, 'h'));
answer.insert(std::map<long, char>::value_type(17740759, 'h'));
answer.insert(std::map<long, char>::value_type(389894501, 'h'));
answer.insert(std::map<long, char>::value_type(808398820, 'h'));
answer.insert(std::map<long, char>::value_type(454529386, 'h'));
answer.insert(std::map<long, char>::value_type(404251154, 'h'));
answer.insert(std::map<long, char>::value_type(7025, 'h'));
answer.insert(std::map<long, char>::value_type(826673, 'h'));
answer.insert(std::map<long, char>::value_type(17694102, 'h'));
answer.insert(std::map<long, char>::value_type(388290951, 'h'));
answer.insert(std::map<long, char>::value_type(808398568, 'h'));
answer.insert(std::map<long, char>::value_type(454579162, 'h'));
answer.insert(std::map<long, char>::value_type(388297455, 'h'));
answer.insert(std::map<long, char>::value_type(421805001, 'h'));
answer.insert(std::map<long, char>::value_type(16780606, 'h'));
answer.insert(std::map<long, char>::value_type(17740730, 'h'));
answer.insert(std::map<long, char>::value_type(2470915, 'h'));
answer.insert(std::map<long, char>::value_type(388247419, 'h'));
answer.insert(std::map<long, char>::value_type(421799008, 'h'));
answer.insert(std::map<long, char>::value_type(792442000, 'h'));
answer.insert(std::map<long, char>::value_type(388244555, 'h'));
answer.insert(std::map<long, char>::value_type(33564350, 'h'));
answer.insert(std::map<long, char>::value_type(53244, 'h'));
answer.insert(std::map<long, char>::value_type(3668, 'h'));
answer.insert(std::map<long, char>::value_type(16870555, 'h'));
answer.insert(std::map<long, char>::value_type(17656792, 'h'));
answer.insert(std::map<long, char>::value_type(389164017, 'h'));
answer.insert(std::map<long, char>::value_type(405068190, 'h'));
answer.insert(std::map<long, char>::value_type(404247746, 'h'));
answer.insert(std::map<long, char>::value_type(1694771, 'h'));
answer.insert(std::map<long, char>::value_type(389114489, 'h'));
answer.insert(std::map<long, char>::value_type(808395951, 'h'));
answer.insert(std::map<long, char>::value_type(808401689, 'h'));
answer.insert(std::map<long, char>::value_type(437799052, 'h'));
answer.insert(std::map<long, char>::value_type(776491477, 'h'));
answer.insert(std::map<long, char>::value_type(390761830, 'h'));
answer.insert(std::map<long, char>::value_type(405067961, 'h'));
answer.insert(std::map<long, char>::value_type(388340728, 'h'));
answer.insert(std::map<long, char>::value_type(51155506, 'h'));
answer.insert(std::map<long, char>::value_type(59159, 'h'));
answer.insert(std::map<long, char>::value_type(774847229, 'h'));
answer.insert(std::map<long, char>::value_type(406668854, 'h'));
answer.insert(std::map<long, char>::value_type(33698038, 'h'));
answer.insert(std::map<long, char>::value_type(421021659, 'h'));
answer.insert(std::map<long, char>::value_type(387470537, 'h'));
answer.insert(std::map<long, char>::value_type(19251281, 'h'));
answer.insert(std::map<long, char>::value_type(404200841, 'h'));
answer.insert(std::map<long, char>::value_type(16777992, 'h'));
answer.insert(std::map<long, char>::value_type(777358268, 'h'));
answer.insert(std::map<long, char>::value_type(36074873, 'h'));
answer.insert(std::map<long, char>::value_type(18471269, 'h'));
answer.insert(std::map<long, char>::value_type(405068166, 'h'));
answer.insert(std::map<long, char>::value_type(16920568, 'h'));
answer.insert(std::map<long, char>::value_type(404294148, 'h'));
answer.insert(std::map<long, char>::value_type(404198735, 'h'));
answer.insert(std::map<long, char>::value_type(405024914, 'h'));
answer.insert(std::map<long, char>::value_type(387424389, 'h'));
answer.insert(std::map<long, char>::value_type(421799034, 'h'));
answer.insert(std::map<long, char>::value_type(775665066, 'h'));
answer.insert(std::map<long, char>::value_type(1839961, 'h'));
answer.insert(std::map<long, char>::value_type(791664879, 'h'));
answer.insert(std::map<long, char>::value_type(793358849, 'h'));
answer.insert(std::map<long, char>::value_type(809222388, 'h'));
answer.insert(std::map<long, char>::value_type(437752177, 'h'));
answer.insert(std::map<long, char>::value_type(3297585, 'h'));
answer.insert(std::map<long, char>::value_type(405027529, 'h'));
answer.insert(std::map<long, char>::value_type(388250548, 'h'));
answer.insert(std::map<long, char>::value_type(50338186, 'h'));
answer.insert(std::map<long, char>::value_type(33604269, 'h'));
answer.insert(std::map<long, char>::value_type(387514116, 'h'));
answer.insert(std::map<long, char>::value_type(17650826, 'h'));
answer.insert(std::map<long, char>::value_type(17697202, 'h'));
answer.insert(std::map<long, char>::value_type(389114241, 'h'));
answer.insert(std::map<long, char>::value_type(404198251, 'h'));
answer.insert(std::map<long, char>::value_type(404201349, 'h'));
answer.insert(std::map<long, char>::value_type(387421291, 'h'));
answer.insert(std::map<long, char>::value_type(405021541, 'h'));
answer.insert(std::map<long, char>::value_type(6770, 'h'));
answer.insert(std::map<long, char>::value_type(1693743, 'h'));
answer.insert(std::map<long, char>::value_type(388290999, 'h'));
}
int main(int argc, char* argv[]) {
long lib[] = {1, 1, 4, 27, 256, 3125, 46656, 823543, 16777216, 387420489};
std::map<long, char> answer;
initMap(answer);
char *endptr;
unsigned long start = strtoul(argv[1], &endptr, 10);
unsigned long end = strtoul(argv[2], &endptr, 10);
while(start < end) {
unsigned long init = start;
unsigned long x = start;
unsigned long y;
int count = 0;
while (true) {
if (answer.find(x) != answer.end()) {
std::cout << init << "," << answer[x] << "," << count << std::endl;
break;
}
y = 0;
while(x > 0) {
y += lib[x % 10];
x /= 10;
}
x = y;
count++;
}
start++;
}
return 0;
}
#include "mpi.h"
#include <iostream>
#include <fstream>
#include <map>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
void initMap(std::map<long, char>& answer) {
answer.insert(std::map<long, char>::value_type(1, 'a'));
answer.insert(std::map<long, char>::value_type(3435, 'b'));
answer.insert(std::map<long, char>::value_type(421845123, 'c'));
answer.insert(std::map<long, char>::value_type(16780890, 'c'));
answer.insert(std::map<long, char>::value_type(16777500, 'd'));
answer.insert(std::map<long, char>::value_type(2520413, 'd'));
answer.insert(std::map<long, char>::value_type(3418, 'd'));
answer.insert(std::map<long, char>::value_type(809265896, 'e'));
answer.insert(std::map<long, char>::value_type(808491852, 'e'));
answer.insert(std::map<long, char>::value_type(437755524, 'e'));
answer.insert(std::map<long, char>::value_type(1657004, 'e'));
answer.insert(std::map<long, char>::value_type(873583, 'e'));
answer.insert(std::map<long, char>::value_type(34381154, 'e'));
answer.insert(std::map<long, char>::value_type(16780909, 'e'));
answer.insert(std::map<long, char>::value_type(792488396, 'e'));
answer.insert(std::map<long, char>::value_type(791621579, 'f'));
answer.insert(std::map<long, char>::value_type(776537851, 'f'));
answer.insert(std::map<long, char>::value_type(19300779, 'f'));
answer.insert(std::map<long, char>::value_type(776488094, 'f'));
answer.insert(std::map<long, char>::value_type(422669176, 'f'));
answer.insert(std::map<long, char>::value_type(388384265, 'f'));
answer.insert(std::map<long, char>::value_type(50381743, 'f'));
answer.insert(std::map<long, char>::value_type(17604196, 'f'));
answer.insert(std::map<long, char>::value_type(388337603, 'f'));
answer.insert(std::map<long, char>::value_type(34424740, 'f'));
answer.insert(std::map<long, char>::value_type(824599, 'f'));
answer.insert(std::map<long, char>::value_type(793312220, 'g'));
answer.insert(std::map<long, char>::value_type(388244100, 'g'));
answer.insert(std::map<long, char>::value_type(33554978, 'g'));
answer.insert(std::map<long, char>::value_type(405027808, 'g'));
answer.insert(std::map<long, char>::value_type(34381363, 'g'));
answer.insert(std::map<long, char>::value_type(16824237, 'g'));
answer.insert(std::map<long, char>::value_type(17647707, 'g'));
answer.insert(std::map<long, char>::value_type(3341086, 'g'));
answer.insert(std::map<long, char>::value_type(16824184, 'g'));
answer.insert(std::map<long, char>::value_type(33601606, 'g'));
answer.insert(std::map<long, char>::value_type(140025, 'g'));
answer.insert(std::map<long, char>::value_type(3388, 'g'));
answer.insert(std::map<long, char>::value_type(33554486, 'g'));
answer.insert(std::map<long, char>::value_type(16830688, 'g'));
answer.insert(std::map<long, char>::value_type(50424989, 'g'));
answer.insert(std::map<long, char>::value_type(791621836, 'g'));
answer.insert(std::map<long, char>::value_type(405114593, 'g'));
answer.insert(std::map<long, char>::value_type(387427281, 'g'));
answer.insert(std::map<long, char>::value_type(35201810, 'g'));
answer.insert(std::map<long, char>::value_type(16780376, 'g'));
answer.insert(std::map<long, char>::value_type(18517643, 'g'));
answer.insert(std::map<long, char>::value_type(17650825, 'g'));
answer.insert(std::map<long, char>::value_type(17653671, 'g'));
answer.insert(std::map<long, char>::value_type(1743552, 'g'));
answer.insert(std::map<long, char>::value_type(830081, 'g'));
answer.insert(std::map<long, char>::value_type(33554462, 'g'));
answer.insert(std::map<long, char>::value_type(53476, 'g'));
answer.insert(std::map<long, char>::value_type(873607, 'g'));
answer.insert(std::map<long, char>::value_type(18470986, 'g'));
answer.insert(std::map<long, char>::value_type(421845378, 'g'));
answer.insert(std::map<long, char>::value_type(34381644, 'g'));
answer.insert(std::map<long, char>::value_type(16824695, 'g'));
answer.insert(std::map<long, char>::value_type(404294403, 'g'));
answer.insert(std::map<long, char>::value_type(387421546, 'g'));
answer.insert(std::map<long, char>::value_type(17651084, 'g'));
answer.insert(std::map<long, char>::value_type(17650799, 'g'));
answer.insert(std::map<long, char>::value_type(776537847, 'g'));
answer.insert(std::map<long, char>::value_type(20121452, 'g'));
answer.insert(std::map<long, char>::value_type(3396, 'g'));
answer.insert(std::map<long, char>::value_type(387467199, 'g'));
answer.insert(std::map<long, char>::value_type(1583236420, 'h'));
answer.insert(std::map<long, char>::value_type(16827317, 'h'));
answer.insert(std::map<long, char>::value_type(18470991, 'h'));
answer.insert(std::map<long, char>::value_type(792441996, 'h'));
answer.insert(std::map<long, char>::value_type(1163132183, 'h'));
answer.insert(std::map<long, char>::value_type(16823961, 'h'));
answer.insert(std::map<long, char>::value_type(404291050, 'h'));
answer.insert(std::map<long, char>::value_type(387424134, 'h'));
answer.insert(std::map<long, char>::value_type(17601586, 'h'));
answer.insert(std::map<long, char>::value_type(17697199, 'h'));
answer.insert(std::map<long, char>::value_type(1163955211, 'h'));
answer.insert(std::map<long, char>::value_type(387473430, 'h'));
answer.insert(std::map<long, char>::value_type(18424896, 'h'));
answer.insert(std::map<long, char>::value_type(421022094, 'h'));
answer.insert(std::map<long, char>::value_type(387421016, 'h'));
answer.insert(std::map<long, char>::value_type(17647705, 'h'));
answer.insert(std::map<long, char>::value_type(2520668, 'h'));
answer.insert(std::map<long, char>::value_type(16873662, 'h'));
answer.insert(std::map<long, char>::value_type(17740759, 'h'));
answer.insert(std::map<long, char>::value_type(389894501, 'h'));
answer.insert(std::map<long, char>::value_type(808398820, 'h'));
answer.insert(std::map<long, char>::value_type(454529386, 'h'));
answer.insert(std::map<long, char>::value_type(404251154, 'h'));
answer.insert(std::map<long, char>::value_type(7025, 'h'));
answer.insert(std::map<long, char>::value_type(826673, 'h'));
answer.insert(std::map<long, char>::value_type(17694102, 'h'));
answer.insert(std::map<long, char>::value_type(388290951, 'h'));
answer.insert(std::map<long, char>::value_type(808398568, 'h'));
answer.insert(std::map<long, char>::value_type(454579162, 'h'));
answer.insert(std::map<long, char>::value_type(388297455, 'h'));
answer.insert(std::map<long, char>::value_type(421805001, 'h'));
answer.insert(std::map<long, char>::value_type(16780606, 'h'));
answer.insert(std::map<long, char>::value_type(17740730, 'h'));
answer.insert(std::map<long, char>::value_type(2470915, 'h'));
answer.insert(std::map<long, char>::value_type(388247419, 'h'));
answer.insert(std::map<long, char>::value_type(421799008, 'h'));
answer.insert(std::map<long, char>::value_type(792442000, 'h'));
answer.insert(std::map<long, char>::value_type(388244555, 'h'));
answer.insert(std::map<long, char>::value_type(33564350, 'h'));
answer.insert(std::map<long, char>::value_type(53244, 'h'));
answer.insert(std::map<long, char>::value_type(3668, 'h'));
answer.insert(std::map<long, char>::value_type(16870555, 'h'));
answer.insert(std::map<long, char>::value_type(17656792, 'h'));
answer.insert(std::map<long, char>::value_type(389164017, 'h'));
answer.insert(std::map<long, char>::value_type(405068190, 'h'));
answer.insert(std::map<long, char>::value_type(404247746, 'h'));
answer.insert(std::map<long, char>::value_type(1694771, 'h'));
answer.insert(std::map<long, char>::value_type(389114489, 'h'));
answer.insert(std::map<long, char>::value_type(808395951, 'h'));
answer.insert(std::map<long, char>::value_type(808401689, 'h'));
answer.insert(std::map<long, char>::value_type(437799052, 'h'));
answer.insert(std::map<long, char>::value_type(776491477, 'h'));
answer.insert(std::map<long, char>::value_type(390761830, 'h'));
answer.insert(std::map<long, char>::value_type(405067961, 'h'));
answer.insert(std::map<long, char>::value_type(388340728, 'h'));
answer.insert(std::map<long, char>::value_type(51155506, 'h'));
answer.insert(std::map<long, char>::value_type(59159, 'h'));
answer.insert(std::map<long, char>::value_type(774847229, 'h'));
answer.insert(std::map<long, char>::value_type(406668854, 'h'));
answer.insert(std::map<long, char>::value_type(33698038, 'h'));
answer.insert(std::map<long, char>::value_type(421021659, 'h'));
answer.insert(std::map<long, char>::value_type(387470537, 'h'));
answer.insert(std::map<long, char>::value_type(19251281, 'h'));
answer.insert(std::map<long, char>::value_type(404200841, 'h'));
answer.insert(std::map<long, char>::value_type(16777992, 'h'));
answer.insert(std::map<long, char>::value_type(777358268, 'h'));
answer.insert(std::map<long, char>::value_type(36074873, 'h'));
answer.insert(std::map<long, char>::value_type(18471269, 'h'));
answer.insert(std::map<long, char>::value_type(405068166, 'h'));
answer.insert(std::map<long, char>::value_type(16920568, 'h'));
answer.insert(std::map<long, char>::value_type(404294148, 'h'));
answer.insert(std::map<long, char>::value_type(404198735, 'h'));
answer.insert(std::map<long, char>::value_type(405024914, 'h'));
answer.insert(std::map<long, char>::value_type(387424389, 'h'));
answer.insert(std::map<long, char>::value_type(421799034, 'h'));
answer.insert(std::map<long, char>::value_type(775665066, 'h'));
answer.insert(std::map<long, char>::value_type(1839961, 'h'));
answer.insert(std::map<long, char>::value_type(791664879, 'h'));
answer.insert(std::map<long, char>::value_type(793358849, 'h'));
answer.insert(std::map<long, char>::value_type(809222388, 'h'));
answer.insert(std::map<long, char>::value_type(437752177, 'h'));
answer.insert(std::map<long, char>::value_type(3297585, 'h'));
answer.insert(std::map<long, char>::value_type(405027529, 'h'));
answer.insert(std::map<long, char>::value_type(388250548, 'h'));
answer.insert(std::map<long, char>::value_type(50338186, 'h'));
answer.insert(std::map<long, char>::value_type(33604269, 'h'));
answer.insert(std::map<long, char>::value_type(387514116, 'h'));
answer.insert(std::map<long, char>::value_type(17650826, 'h'));
answer.insert(std::map<long, char>::value_type(17697202, 'h'));
answer.insert(std::map<long, char>::value_type(389114241, 'h'));
answer.insert(std::map<long, char>::value_type(404198251, 'h'));
answer.insert(std::map<long, char>::value_type(404201349, 'h'));
answer.insert(std::map<long, char>::value_type(387421291, 'h'));
answer.insert(std::map<long, char>::value_type(405021541, 'h'));
answer.insert(std::map<long, char>::value_type(6770, 'h'));
answer.insert(std::map<long, char>::value_type(1693743, 'h'));
answer.insert(std::map<long, char>::value_type(388290999, 'h'));
}
int main(int argc, char* argv[]) {
int rank, size;
MPI::Init(argc, argv);
rank = MPI::COMM_WORLD.Get_rank();
size = MPI::COMM_WORLD.Get_size();
long lib[] = {1, 1, 4, 27, 256, 3125, 46656, 823543, 16777216, 387420489};
std::map<long, char> answer;
initMap(answer);
char *endptr;
unsigned long start = strtoul(argv[1], &endptr, 10);
unsigned long end = strtoul(argv[2], &endptr, 10);
unsigned long jobLen = end - start;
end = (jobLen / size) * (rank + 1) + (std::min)(rank + 1, (int)(jobLen % size)) + start;
start = (jobLen / size) * rank + (std::min)(rank, (int)(jobLen % size)) + start;
char tmp[128];
sprintf(tmp, "%d-%d", start, end);
std::ofstream fout(tmp);
while(start < end) {
unsigned long init = start;
unsigned long x = start;
unsigned long y;
int count = 0;
while (true) {
if (answer.find(x) != answer.end()) {
//std::cout << init << "," << answer[x] << "," << count << std::endl;
fout << init << "," << answer[x] << "," << count << std::endl;
break;
}
y = 0;
while(x > 0) {
y += lib[x % 10];
x /= 10;
}
x = y;
count++;
}
start++;
}
MPI::COMM_WORLD.Barrier();
MPI::Finalize();
return 0;
}
import os
num = {}
num["a"] = 0
num["b"] = 0
num["c"] = 0
num["d"] = 0
num["e"] = 0
num["f"] = 0
num["g"] = 0
num["h"] = 0
def func():
maxCount = 0
maxNum = 0
for f in os.listdir("calc"):
fp = open("calc/" + f)
for line in fp:
l = line.split(",")
num[l[1]] += 1
if int(l[2]) > maxCount:
maxCount = int(l[2])
maxNum = line
fp.close()
print num
print maxNum
func()
Output 'a': 1, 'b': 75677, 'c': 3498529, 'd': 12436682, 'e': 37313370, 'f': 13088041, 'g': 1251010528, 'h': 1682577172}
import os
def func():
for f in os.listdir("calc"):
fp = open("calc/" + f)
for line in fp:
l = line.split(",")
if int(l[2]) == 124:
print line
fp.close()
func()
Output 1022355577,h,124
f[n_]:=Block[{k},k=findloop[n];
NestList[dsf,n,k[[2]]]];
ss={{0,0,0},{0,0,1},{0,1,0},{0,1,1},{1,0,0},{1,0,1},{1,1,0},
{1,1,1}};
counter={0,0,0,0,0,0,0,0};
Do[mm=RandomInteger[{20,200000}];dd=Map[Mod[#,2]&,f[mm]];
data=Table[{dd[[n]],dd[[n+1]],dd[[n+2]]},{n,1,
Length[dd]-2}];
counter=counter+Table[Count[data,ss[[m]]],{m,1,8}],{mm,1,
1000}];counter
The output of this program is
dsf5000[n_]:=Block[{m=n,t},t=IntegerDigits[m];
findloop5000[n_]:=Block[{m=n,u,dat},dat={m};
m=dsf5000[m];
While[!MemberQ[dat,m],dat=Append[dat,m];m=dsf5000[m]];
dat=Append[dat,m];
u=Flatten[Position[dat,Last[dat]]];
{n,u[[1]]-1,Last[dat],u[[2]]-u[[1]]}];
NestList[dsf5000, 16, 8]The out put for this is {16, 1657, 3325, 3183, 2271, 3552, 1281, 2222, 16}, and this shows that loop8 is a loop.
data5 = Union[Table[Nest[dsf5000, n, 5], {n, 0, 4999}]];
{1, 4, 6, 13, 16, 28, 29, 33, 36, 37, 54, 56, 204, 226, 227, 253,
256, 261, 262, 271, 287, 288, 291, 297, 311, 342, 455, 459, 492, 493,
494, 495, 514, 518, 520, 540, 624, 747, 749, 763, 764, 772, 773, 787,
790, 795, 857, 1001, 1016, 1042, 1255, 1275, 1278, 1281, 1438, 1506,
1656, 1657, 1659, 1661, 1662, 1664, 1669, 1673, 1683, 1696, 1856,
1912, 1916, 1925, 1940, 1943, 1998, 2090, 2091, 2113, 2147, 2150,
2153, 2157, 2161, 2173, 2176, 2195, 2220, 2222, 2228, 2245, 2248,
2271, 2274, 2297, 2342, 2346, 2405, 2477, 2480, 2500, 2759, 2831,
2962, 3130, 3131, 3156, 3157, 3183, 3195, 3221, 3314, 3317, 3325,
3340, 3366, 3381, 3382, 3386, 3389, 3435, 3548, 3551, 3552, 3569,
3570, 3575, 3598, 3616, 3619, 3642, 3742, 3802, 3804, 3807, 3830,
3870, 3884, 3897, 3899, 3900, 3911, 3926, 4033, 4036, 4040, 4140,
4288, 4302, 4434, 4436, 4692, 4715, 4781, 4783, 4785, 4809, 4820}
gc5000[n_]:=Block[{m=n,u,dat},dat={m};m=dsf5000[m];
While[!MemberQ[dat,m],dat=Append[dat,m];m=dsf5000[m]];
dat=Append[dat,m];Last[dat]];
loop1A={1};loop1B={1255};loop1C={2228};loop1D={3366};
loop1E={3435};loop3={13,28,2220};loop8={16,1657,3325,
3183,2271,3552,1281,2222};loop12={56,4781,1016,1659,271,
3548,624,1916,2147,3804,2500,3131};
elementofloop5000=
Join[loop1A,loop1B,loop1C,loop1D,loop1E,loop3,loop8,loop12];
d=Union[Table[gc5000[data5[[n]]],{n,1,155}]];
Complement[d, elementofloop5000]
The output of this is { }, and hence we have proved that for any
dfsf[x_]:=Apply[Plus,(IntegerDigits[x])!];
acknowledgments.
We would like to thank Hiroaki Simoda, Hiroki Takebayashi, Naoya Urakawa, Takuma Nakaoka, Kousuke Morimoto, Norihiko Yamaguchi, Koichi Tukiyama and Satoshi Hashiba for their contribution in presenting many ideas in this article.