TI-BASIC(TI-84),30 32 31字节
-1个字节感谢@SolomonUcko!
While Ans>9:Disp Ans:prod(int(10fPart(Ans10^(seq(-X-1,X,0,log(Ans:End:Ans
输入为Ans
。
输出显示为质询请求。Ans
打印最后一步需要尾随。
我承认,我自己并没有想到这个公式,而是在这里找到并修改了它以更好地应对挑战。
编辑: 重新阅读挑战后,我意识到,如果乘积是一位数字,则程序必须终止。因此,要为此添加2个字节。
例:
24456756
24456756
prgmCDGF8
24456756
201600
0
11112
11112
prgmCDGF8
11112
2
说明:
While Ans>9 ;loop until the product is one digit
Disp Ans ;display the current product
prod( ;get the product of...
int( ; the integer part of...
10fPart( ; ten times the fractional part of...
Ans ; each element in the following list times the
; current product
10^( ; multiplied by the list generated by using each
; element of the following list as an exponent
; for 10^n
seq(-X-1),X,0,log(Ans ; generate a list of exponents from -1 to -L where
; L = the length of the current product
End
Ans ;leave the final product in "Ans" and implicitly
; print it
视觉模型:
Ans
从开始125673
。
该模型仅涵盖了将数字相乘的逻辑。其他所有内容都更容易理解。
seq(-X-1,X,0,log(Ans => seq(-X-1,X,0,5.0992
{-1 -2 -3 -4 -5 -6}
10^(...
{.1 .01 .001 1E-4 1E-5 1E-6}
Ans...
{12567.3 1256.73 125.673 12.5673 1.25673 .125673}
fPart(...
{.3 .73 .673 .5673 .25673 .125673}
10...
{3 7.3 6.73 5.673 2.5673 1.25673}
int(...
{3 7 6 5 2 1}
(the digits of the number, reversed)
prod(...
1260
(process is repeated again)
seq(-X-1,X,0,log(Ans => seq(-X-1,X,0,3.1004
{-1 -2 -3 -4}
10^(...
{.1 .01 .001 1E-4}
Ans...
{126 12.6 1.26 .126}
fPart(...
{0 .6 .26 .126}
10...
{0 6 2.6 1.26}
int(...
{0 6 2 1}
prod(...
0
(product is less than 10. loop ends)
笔记:
TI-BASIC是一种标记化语言。字符数不不等于字节数。
10^(
是这个一字节的令牌。
由于TI计算器的小数精度限制,该程序将无法提供长度大于14位整数的正确乘积序列。