Robert was surfing the internet recently, and found a reference to polygonal numbers. These are series such as the triangular numbers, pentagonal numbers and others, including the series of heptagonal numbers, which starts 1, 7, 18, 34…
Robert asked his nephew, Sam to tell him the next member of this series, which he said was 55. Later Sam told Robert that he had found a set of six consecutive heptagonal numbers, all less than two million, where the difference between the first and last was divisible by all of the digits 1 to 9. One of the intermediate heptagonal numbers in this set was divisible by just four of these digits.
What was this heptagonal number?
Note: Adapted from Enigma Number:1672 by Adrian Sommerfield, which appered in the New Scientist on 9 November, 2011.
clc
for i=1:10000
diff=heptagonal(i+5)-heptagonal(i);
good=true;
for j=2:9
if mod(diff,j)~=0
good=false;
break
end
end
if good
good=false;
for j=i+1:i+4
dCt=0;
for k=1:9
if mod(heptagonal(j),k)==0
dCt=dCt+1;
end
end
end
if dCt==4
good=true;
end
end
if good
for j=i:i+5
fprintf(' %d ',heptagonal(j));
dCt=0;
for k=1:9
if mod(heptagonal(j),k)==0
dCt=dCt+1;
end
end
fprintf('%d \n',dCt)
end
fprintf('\n');
end
end
function v=heptagonal(n)
v=(5*n^2-3*n)/2;
end
Only the first set below has heptagonals that are under 2 million. Each heptagonal is followed by the count of divisibilities by single-digit numbers.
409455 is divisible by 1, 3, 5 and 9, but no other single digit number.
Also 411481-401401 = 10080 is divisible by all the single-digit integers.
The heptagonals in the first group are the 401st through 406th heptagonal.
401401 2
403407 3
405418 2
407434 2
409455 4
411481 2
21326221 2
21340827 3
21355438 2
21370054 2
21384675 4
21399301 2
74003041 2
74030247 3
74057458 2
74084674 2
74111895 4
74139121 2
158431861 2
158471667 3
158511478 2
158551294 2
158591115 4
158630941 2
|
Posted by Charlie
on 2024-09-02 13:56:35 |