Find a sequence of consecutive integers, a, a+1, a+2, ..., b such that b is a square and that:
[a+(a+1)+(a+2)+...+(b-1)]b and [(a-1)+a+(a+1)+(a+2)+...+(b-1)]b are both 10-digit numbers containing all of the digits 0 to 9.
clc
for sr=10:450
b=sr^2;
for a=1:b-2
v1=(b-a)*(a+b-1)/2 * b;
if v1>=1023456789 && v1<=9876543210
vs=char(string(v1));
if length(unique(vs))==10
v2=(b-a+1)*(a+b-2)/2 * b;
if v2>=1023456789 && v2<=9876543210
vs=char(string(v2));
if length(unique(vs))==10
fprintf('%d ',a, b, sr, v1, v2)
fprintf('\n')
end
end
end
end
end
end
finds
a=78
b=1296 which is 36^2
The two 10-digit numbers are 1083659472 and 1083759264.
Verification using direct summation rather than summation formula:
>> sum(78:1296-1)
ans =
836157
>> ans*1296
ans =
1083659472
>> sum(78-1:1296-1)
ans =
836234
>> ans*1296
ans =
1083759264
|
Posted by Charlie
on 2023-12-25 09:00:01 |