[seqfan] Re: Kaprekar Triples
Jack Brennen
jfb at brennen.net
Wed Aug 23 19:20:32 CEST 2017
C program (starts with 3 digit numbers, should be good until you get
64-bit unsigned integer overflows):
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
uint64_t DELTA[3];
uint64_t D[3];
uint64_t Q[2];
uint64_t I,J,BASE,CARRY;
// DELTA is the difference between I^3 and (I+1)^3,
// expressed as three digits of base B.
// Note that it's equal to 3*I^2+3*I+1,
// and that it increments each time by 6*I+6.
for (J=100, BASE=1000; ; J*=10, BASE*=10) {
D[0] = 0;
D[1] = 0;
D[2] = BASE/1000;
DELTA[0] = 3*J+1;
DELTA[1] = (3*J)/10;
DELTA[2] = 0;
Q[0] = 6*J+6;
Q[1] = 0;
for (I=J+1; I<BASE; I++) {
D[0] += DELTA[0]; if (D[0] >= BASE) { D[0] -= BASE; CARRY=1; }
else { CARRY=0; }
D[1] += DELTA[1]+CARRY; if (D[1] >= BASE) { D[1] -= BASE;
CARRY=1; } else { CARRY=0; }
D[2] += DELTA[2]+CARRY;
if (D[2]+D[1]+D[0] == I) {
printf("%llu, ", (unsigned long long)I);
fflush(stdout);
}
DELTA[0] += Q[0]; if (DELTA[0] >= BASE) { DELTA[0] -= BASE;
CARRY=1; } else { CARRY=0; }
DELTA[1] += Q[1]+CARRY; if (DELTA[1] >= BASE) { DELTA[1] -=
BASE; CARRY=1; } else { CARRY=0; }
DELTA[2] += CARRY;
Q[0] += 6; if (Q[0] >= BASE) { Q[0] -= BASE; Q[1] += 1; }
}
}
}
Output from the first few minutes of running the program:
297, 2322, 2728, 4445, 4544, 4949, 5049, 5455, 5554, 7172, 27100, 44443,
55556, 60434, 77778, 143857, 208494, 226071, 279720, 313390, 324675,
329967, 346060, 368928, 395604, 422577, 427868, 461539, 472823, 478115,
488214, 494208, 495208, 499500, 500500, 517076, 533170, 543752, 559846,
565137, 598807, 664741, 670032, 720279, 757835, 791505, 807598, 825175,
829466, 856142, 966329, 973323, 4444443, 4927940, 5072058, 5555555,
5555556, 5699673, 6183170, 8888887, 11273318, 13793570, 17090613,
21803275, 22293325, 24752475, 25242525, 25252524, 27272728, 27282727,
28201724, 30731977, 33404436, 36363635, 38383839, 38546045, 38883889,
39046095, 39546145, 41843088, 44025497, 44363340, 44525547, 45025597,
47045800, 49842793, 49995000, 50005000, 50657256, 55474451, 55474452,
55484452, 56136708, 58156911, 58656961, 60453854, 61453954, 63636364,
63798570, 64298620, 66747770, 69278022, 69768072, 69778072, 72227222,
72717272, 72727271, 74747475, 74909681, 75409731, 77706674, 77767777,
77777776, 80726976, 80726977, 80889183, 88878888, 88888888, 93868290,
197864531, 332999667, 667000332, 765432098, 1111111110, 1153093348,
1355013550, 1396995787, 2020202019, 2020202020, 2112639308, 2306086696,
2685390489, 2887410691, 2979847980, 3131313130, 3181768182, 3265632656,
3467652858, 3645036449, 3846956651, 3888938889, 4132741328, 4174723565,
4292879293, 4756047560, 4798029798, 4958067762, 4999950000, 5000050000,
5041932236, 5243952438, 5243952439, 5445872641, 5487854878, 5623256232,
5707120706, 5867258671, 5909040908, 5909140908, 5909140909, 6111061110,
6111161110, 6153043348, 6355063549, 6574329378, 6776249580, 7020252019,
7070707071, 7222172221, 7264154458, 7356491747, 7558511949, 7643458252,
7685440489, 7777777778, 7777877777, 8021680217, 8173245367, 8669623060,
8888888889, 9174773564, 9512095121, 9512195120, 9755997560, 9839962034,
24138656648, 31416898906, 44444444445,
On 8/23/2017 9:02 AM, Hans Havermann wrote:
> https://oeis.org/A006887
>
> On Monday, Futility Closet's "Math Notes" showcased five terms of this sequence:
>
> https://www.futilitycloset.com/2017/08/21/math-notes-116/
>
> The OEIS's 35 given terms date to 2003. A lot of computational power has evolved since. Perhaps someone can provide "more". A program also would be nice.
>
> --
> Seqfan Mailing list - http://list.seqfan.eu/
>
>
>
More information about the SeqFan
mailing list