Skip to content

Commit 91bb091

Browse files
authored
Add Zeckendorf in TI-BASIC (#5344)
1 parent f31ffec commit 91bb091

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Input "",Str1
2+
"0123456789"->Str2
3+
length(Str1)->L
4+
L<1->E
5+
0->D
6+
0->V
7+
1->N
8+
1->S
9+
While E=0 and N<=L
10+
sub(Str1,N,1)->C
11+
inString(Str2,C)-1->K
12+
If C="+" or C="-"
13+
Then
14+
D>0->E
15+
If C="-"
16+
Then 0-S->S
17+
End
18+
Else
19+
K<0->E
20+
D+1->D
21+
V*10+K*S->V
22+
End
23+
N+1->N
24+
End
25+
If E or D<1 or V<0->E Then Disp "Usage: please input a non-negative integer"
26+
Else
27+
1->A
28+
2->B
29+
While A<=V
30+
B+A->B
31+
B-A->A
32+
End
33+
{}->l1
34+
0->N
35+
While V>0
36+
B-A->A
37+
B-A->B
38+
If V>=A Then
39+
N+1->N
40+
A->l1(N)
41+
V-A->V
42+
End
43+
End
44+
End
45+
If l1 Then
46+
Disp l1
47+
End

0 commit comments

Comments
 (0)