TI-BASIC 66 62 바이트
Ans→N:While X<N:IS>(A,A::A:prgmA:Ans→B:A²:prgmA:If B=Ans:IS>(X,N:End:A
sum(int(10fPart(Ans₁₀^(seq(⁻X-1,X,0,log(Ans
nAns
n
도우미 함수는에 값의 자릿수 합계를 생성합니다 Ans
.
예 :
3:prgmCDGF1E
10
5:prgmCDGF1E
19
8:prgmCDGF1E
55
10:prgmCDGF1E
99
설명:
Ans→N:While X<N:IS>(A,A::A:prgmA:Ans→B:A²:prgmA:If B=Ans:IS>(X,N:End:A ;prgmCDGF1E
Ans→N ;store the input in N
While X<N ;loop until the Nth term has been reached
IS>(A,A: ;add 1 to A
; (Increment A and skip the next statement if A>A)
A ;leave A in Ans
prgmA ;call the helper program below
Ans→B ;store the result of the helper program in B
A² ;square A and leave the result in Ans
prgmA ;call the helper program below
; (result is in Ans)
If B=Ans ;if the two results are equal
IS>(X,N ;add 1 to X
; (Increment X and skip the next statement if X>N)
End
A ;leave A in Ans
;implicit print of Ans
sum(int(10fPart(Ans₁₀^(seq(⁻X-1,X,0,log(Ans ;prgmA
seq(⁻X-1,X,0,log(Ans ;generate a list...
; using X as the variable,
; starting at 0,
; ending at the log of Ans,
; and evaluating "⁻X-1" for each element
; (implicit increment of 1)
₁₀^( ;raise 10 to the power of each element
Ans ;multiply each element by the input
fPart( ;remove the integer part from each element
10 ;multiply each element by 10
int( ;round each element to the nearest integer
sum( ;then sum the resulting list
참고 : TI-BASIC은 토큰 화 된 언어입니다. 문자 수는 바이트 수와 같지 않습니다 .