这个是在AutoHotKey中文社区参与的一个小任务游戏。

查尔斯·巴贝奇(1791年12月26日-1871年10月18日),英国数学家、发明家兼机械工程师。由于提出了差分机与分析机的设计概念(并有部分实做机器),被视为计算机先驱。他曾经预测自己的机器能够解决的诸多问题,并举了一个例子:

What is the smallest positive integer whose square ends in the digits 269,696?

— Babbage, letter to Lord Bowden, 1837; see Hollingdale and Tootill,?Electronic Computers, second edition, 1970, p. 125.

找到一个最小的正整数,他的平方以269696结尾。

他猜测这个数是 99,736,其平方等于 9,947,269,696,但是他本人也无法确定这个答案是否正确。

任务

求出巴贝奇问题的正确答案。

我写的一段代码,求出的最小整数是:25264,留个纪念。

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Persistent	;保持后台运行
#SingleInstance FORCE ;单实例运行模式
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%
SetWorkingDir %A_WorkingDir%  ; Ensures a consistent starting directory.
SetBatchLines -1
ListLines Off

res1:="269696"

Gui, +LastFound +ToolWindow +AlwaysOnTop
Gui, Color, EAEAEA,2b2b2b
gui,margin,30,30
GUI, Font, w200 Q5 s10 c2b2b2b , Microsoft Yahei
GUI, ADD, BUTTON, Y+30 W200 default gstart, 开始
GUI, ADD, BUTTON, Y+30 W200  gcancleme, 停止
GUI, ADD, text, Y+20, Babbage result is ...
GUI, Font, w200 Q5 s16 cred bold , Microsoft Yahei
GUI, ADD, text, Y+10 w250 , % "calculating..."
gui,show,autosize center, Babbage problem

return

start:
loop
{
temp1:=a_index . res1
temp2:=sqrt(temp1)
temp3:=round(temp2,0)+0
temp4:=temp3**2

	if (temp1=temp4)
	{
		babbage_res:=round(temp2,0)+0
		guicontrol,,static2, % babbage_res
		break
	}

}
return

cancleme:
exitapp
return

?

补充一个这个数字的规律:

数字结构是 第一部分+第二部分+第三部分

第三部分在奇数序号时为4,偶数序号时候6

第二部分在奇数时为26,偶数为73

第一部分在1序号时为5*5,后面的序列逢偶数序号为(上一个奇数位值+15)*5-1,逢奇数序号为(上一个偶数位数值+10)*5

把三部分合并起来的数字,其平方的最后6为就是269696

如第一个是:5*5=25;26;4;合并起来就是25264

第二个是:(5+15)*5-1=99;73;6,合并起来就是99763

第三个是:(5+15+10)*5=150;26;4;合并起来就是150264

第四个是:(5+15+10+15)*5-1=224;73;6,合并起来就是224763

……

?

?