Where in the decimal representation of π^2 do the first N digits of π appear?
When I say "the first N digits of π", I mean counting the integer 3 but not counting the decimal point. For example, the first 5 digits of π are 31415.
Define the function pp2(N) as the N-th digit of π^2 where the first N digits of π are seen for the first time (after the decimal point).
So, pp2(1) = 13, because π^2 is approximately 9.869604401089358 and the first digit of pi, '3', first appears as the 13th digit after the decimal point.
Please find pp2(N) for N = 2,3,4,5.
digits 400000
begin='314159';
p=char(vpa(pi)^2);
p=p(3:end);
for n=1:5
pp2=strfind(p,begin(1:n));
pp2=pp2(1);
fprintf('%2d %6d %s\n',n,pp2,p(pp2-5:pp2+8))
end
finds
N pp2(N) in context
|
v
1 13 01089358618834
2 37 51135313699407
3 114 77402314407777
4 7008 13824314152676
5 7008 13824314152676
Going one farther:
digits 4000000
begin='314159';
p=char(vpa(pi)^2);
p=p(3:end);
for n=1:6
pp2=strfind(p,begin(1:n));
pp2=pp2(1);
fprintf('%2d %6d %s\n',n,pp2,p(pp2-5:pp2+8))
end
N pp2(N) in context
|
v
1 13 01089358618834
2 37 51135313699407
3 114 77402314407777
4 7008 13824314152676
5 7008 13824314152676
6 543623 14502314159763
|
Posted by Charlie
on 2023-04-27 08:56:35 |