login
Numbers n such that the digits of P_7(n), the n-th heptagonal number, end in n.
0

%I #8 Feb 11 2014 19:05:25

%S 1,4,5,8,9,16,25,40,41,56,65,80,81,96,176,225,400,401,576,625,800,801,

%T 976,1376,2625,4000,4001,5376,6625,8000,8001,9376,10625,29376,40000,

%U 40001,50625,69376,80000,80001,90625

%N Numbers n such that the digits of P_7(n), the n-th heptagonal number, end in n.

%C Recall that P_7(n) = n(5n-3)/2.

%e P_7(n) = 188, ending in 8. Hence 8 is a term of the sequence.

%t (*returns true if a ends with b, false o.w.*) f[a_, b_] := Module[{c, d, e, g, h, i, r}, r = False; c = ToString[a]; d = ToString[b]; e = StringLength[c]; g = StringPosition[c, d]; h = Length[g]; If[h > 0, i = g[[h]]; If[i[[2]] == e, r = True]]; r]; Do[If[f[n(5n-3)/2, n], Print[n]], {n, 1, 10^5} ]

%t Transpose[Select[Table[{n,n (5n-3)/2},{n,100000}],Mod[Last[#], 10^IntegerLength[ First[#]]]==First[#]&]][[1]] (* _Harvey P. Dale_, Jul 12 2011 *)

%K base,nonn

%O 1,2

%A _Joseph L. Pe_, Feb 21 2002