Let us define P(N) as the Nth Pentagonal number and H(N) as the Nth Hexagonal number.
All the positive pentagonal numbers and hexagonal numbers are now considered alternately in order, that is:
P(1), H(2), P(3), H(4), P(5), H(6),.....
Writing these without commas or spaces results in this infinite string:
161228356670120117190......
Determine the 2022th digit in the above pattern. What is the 20220th digit in the above pattern?
*** P(N)= N(3N-1)/2, and, H(N) = N(2N-1), so that:
P(1)=1, H(2)= 6, P(3)= 12, H(4) = 28, P(5) = 35, H(6) = 66, ..... and so on
clc,clearvars
s=char.empty;
i=0;
while length(s)<2022
i=i+1;
if mod(i,2)==1
p=i*(3*i-1)/2;
s=[s char(string(p))];
else
h=i*(2*i-1);
s=[s char(string(h))];
end
end
disp([i p h])
disp([s(2022-10:end) ' ' s(2022)])
disp(' _')
s=char.empty;
i=0;
while length(s)<20220
i=i+1;
if mod(i,2)==1
p=i*(3*i-1)/2;
s=[s char(string(p))];
else
h=i*(2*i-1);
s=[s char(string(h))];
end
end
disp([i p h])
disp([s(20220-10:end) ' ' s(20220)])
disp(' _')
shows
396 233840 313236
0078233840313236 3
2968 13203150 17615080
1320315017615080 6
meaning the 3 that begins the 396th hexagonal number, 313236, is the 2022nd digit of the pattern. (233840 is the 395th pentagonal number.)
and 6 is the 20220th digit in the pattern, from the 2968th hexagonal number, 17615080, which follows 13203150, the 2967th pentagonal number.
|
Posted by Charlie
on 2022-03-10 09:22:40 |