Let y(n) represent sum of digits of n
3.
For 10<n<999 list all the triplets (n,n+1,n+2) such that y(n),y(n+1),y(n+2)
are three successive integers
a.in any order
b.corresponding to n,n+1,n+2.
Part a:
When the y values can be in any order there are 121 solutions:
ct=0;
for n=10:999
ns=[n n+1 n+2];
for i=1:3
nsc(i)=sod(ns(i)^3);
ns2(i)=(ns(i)^3);
end
ns1=nsc;
nsc=sort(nsc);
if nsc(3)-nsc(2)==1 && nsc(2)-nsc(1)==1
disp(ns)
disp(ns1)
disp(ns2)
ct=ct+1;
end
end
disp(ct)
where the function sod is defined by
function sd = sod(n)
s=0;
dgts=num2str(n) ;
l=length(dgts) ;
dgts=string(dgts);
for i=1:l
s=s+double(substr(dgts,i));
end
sd=s;
end
and substr by
function outstr = substr(x,r)
c=char(x);
c2=c(r);
outstr=string(c2);
end
12 13 14 | n n+1 n+2
18 19 17 | sod's of cubes
1728 2197 2744 | the cubes
13 14 15
19 17 18
2197 2744 3375
14 15 16
17 18 19
2744 3375 4096
15 16 17
18 19 17
3375 4096 4913
16 17 18
19 17 18
4096 4913 5832
21 22 23
18 19 17
9261 10648 12167
22 23 24
19 17 18
10648 12167 13824
23 24 25
17 18 19
12167 13824 15625
31 32 33
28 26 27
29791 32768 35937
41 42 43
26 27 28
68921 74088 79507
42 43 44
27 28 26
74088 79507 85184
54 55 56
27 28 26
157464 166375 175616
55 56 57
28 26 27
166375 175616 185193
71 72 73
26 27 28
357911 373248 389017
77 78 79
26 27 28
456533 474552 493039
86 87 88
26 27 28
636056 658503 681472
103 104 105
28 26 27
1092727 1124864 1157625
135 136 137
27 28 26
2460375 2515456 2571353
136 137 138
28 26 27
2515456 2571353 2628072
161 162 163
26 27 28
4173281 4251528 4330747
162 163 164
27 28 26
4251528 4330747 4410944
163 164 165
28 26 27
4330747 4410944 4492125
181 182 183
37 35 36
5929741 6028568 6128487
195 196 197
36 37 35
7414875 7529536 7645373
196 197 198
37 35 36
7529536 7645373 7762392
224 225 226
26 27 28
11239424 11390625 11543176
241 242 243
37 35 36
13997521 14172488 14348907
242 243 244
35 36 37
14172488 14348907 14526784
253 254 255
37 35 36
16194277 16387064 16581375
254 255 256
35 36 37
16387064 16581375 16777216
270 271 272
27 28 26
19683000 19902511 20123648
271 272 273
28 26 27
19902511 20123648 20346417
272 273 274
26 27 28
20123648 20346417 20570824
295 296 297
37 35 36
25672375 25934336 26198073
296 297 298
35 36 37
25934336 26198073 26463592
302 303 304
35 36 37
27543608 27818127 28094464
303 304 305
36 37 35
27818127 28094464 28372625
304 305 306
37 35 36
28094464 28372625 28652616
305 306 307
35 36 37
28372625 28652616 28934443
313 314 315
37 35 36
30664297 30959144 31255875
314 315 316
35 36 37
30959144 31255875 31554496
336 337 338
36 37 35
37933056 38272753 38614472
350 351 352
26 27 28
42875000 43243551 43614208
363 364 365
36 37 35
47832147 48228544 48627125
375 376 377
36 37 35
52734375 53157376 53582633
385 386 387
37 35 36
57066625 57512456 57960603
396 397 398
36 37 35
62099136 62570773 63044792
397 398 399
37 35 36
62570773 63044792 63521199
406 407 408
37 35 36
66923416 67419143 67917312
412 413 414
46 44 45
69934528 70444997 70957944
425 426 427
44 45 46
76765625 77308776 77854483
431 432 433
35 36 37
80062991 80621568 81182737
432 433 434
36 37 35
80621568 81182737 81746504
433 434 435
37 35 36
81182737 81746504 82312875
437 438 439
35 36 37
83453453 84027672 84604519
442 443 444
46 44 45
86350888 86938307 87528384
454 455 456
46 44 45
93576664 94196375 94818816
455 456 457
44 45 46
94196375 94818816 95443993
473 474 475
35 36 37
105823817 106496424 107171875
474 475 476
36 37 35
106496424 107171875 107850176
493 494 495
37 35 36
119823157 120553784 121287375
497 498 499
35 36 37
122763473 123505992 124251499
514 515 516
46 44 45
135796744 136590875 137388096
555 556 557
45 46 44
170953875 171879616 172808693
568 569 570
28 26 27
183250432 184220009 185193000
573 574 575
36 37 35
188132517 189119224 190109375
574 575 576
37 35 36
189119224 190109375 191102976
582 583 584
45 46 44
197137368 198155287 199176704
585 586 587
18 19 17
200201625 201230056 202262003
592 593 594
46 44 45
207474688 208527857 209584584
595 596 597
37 35 36
210644875 211708736 212776173
596 597 598
35 36 37
211708736 212776173 213847192
602 603 604
35 36 37
218167208 219256227 220348864
611 612 613
35 36 37
228099131 229220928 230346397
612 613 614
36 37 35
229220928 230346397 231475544
613 614 615
37 35 36
230346397 231475544 232608375
621 622 623
36 37 35
239483061 240641848 241804367
622 623 624
37 35 36
240641848 241804367 242970624
635 636 637
44 45 46
256047875 257259456 258474853
636 637 638
45 46 44
257259456 258474853 259694072
651 652 653
45 46 44
275894451 277167808 278445077
652 653 654
46 44 45
277167808 278445077 279726264
664 665 666
46 44 45
292754944 294079625 295408296
665 666 667
44 45 46
294079625 295408296 296740963
666 667 668
45 46 44
295408296 296740963 298077632
667 668 669
46 44 45
296740963 298077632 299418309
677 678 679
35 36 37
310288733 311665752 313046839
693 694 695
36 37 35
332812557 334255384 335702375
694 695 696
37 35 36
334255384 335702375 337153536
702 703 704
45 46 44
345948408 347428927 348913664
713 714 715
44 45 46
362467097 363994344 365525875
714 715 716
45 46 44
363994344 365525875 367061696
733 734 735
46 44 45
393832837 395446904 397065375
744 745 746
36 37 35
411830784 413493625 415160936
745 746 747
37 35 36
413493625 415160936 416832723
763 764 765
46 44 45
444194947 445943744 447697125
764 765 766
44 45 46
445943744 447697125 449455096
781 782 783
46 44 45
476379541 478211768 480048687
802 803 804
46 44 45
515849608 517781627 519718464
831 832 833
45 46 44
573856191 575930368 578009537
835 836 837
46 44 45
582182875 584277056 586376253
836 837 838
44 45 46
584277056 586376253 588480472
847 848 849
37 35 36
607645423 609800192 611960049
851 852 853
35 36 37
616295051 618470208 620650477
872 873 874
44 45 46
663054848 665338617 667627624
881 882 883
53 54 55
683797841 686128968 688465387
896 897 898
35 36 37
719323136 721734273 724150792
912 913 914
45 46 44
758550528 761048497 763551944
913 914 915
46 44 45
761048497 763551944 766060875
919 920 921
46 44 45
776151559 778688000 781229961
933 934 935
36 37 35
812166237 814780504 817400375
934 935 936
37 35 36
814780504 817400375 820025856
937 938 939
46 44 45
822656953 825293672 827936019
945 946 947
45 46 44
843908625 846590536 849278123
946 947 948
46 44 45
846590536 849278123 851971392
947 948 949
44 45 46
849278123 851971392 854670349
950 951 952
35 36 37
857375000 860085351 862801408
961 962 963
46 44 45
887503681 890277128 893056347
962 963 964
44 45 46
890277128 893056347 895841344
963 964 965
45 46 44
893056347 895841344 898632125
964 965 966
46 44 45
895841344 898632125 901428696
There are 121.
|
Posted by Charlie
on 2020-10-04 11:57:36 |