07-21-2022, 08:26 AM
Takes a real integer N from the stack & returns A8904(N) to stack.
Last non-zero digit of N!
https://oeis.org/search?q=a8904&sort=&la...&go=Search
Uses the sub-programme V:
Takes a real integer from the stack & stores remainder on division by 5 in R & quotient in Q & returns Q to stack, leaving Y, Z & T stack levels unaltered.
Last non-zero digit of N!
https://oeis.org/search?q=a8904&sort=&la...&go=Search
Code:
1. LBL E
2. STO N
3. 2
4. x≤y?
5. GTO F
6. 1
7. RTN
1. LBL F
2. CLx
3. STO C
4. STO P
5. +
1. LBL G
2. XEQ V
3. RCL R
4. RCL* P
5. 1
6. RCL+R
7. 2
8. RMDR
9. RCL R
10. 2
11. INT/
12. *
13. +
14. STO+ C
15. 1
16. STO+ P
17. RCL Q
18. x≠0?
19. GTO G
20. 2
21. RCL C
22. 4
23. RMDR
24. y^x
25. 1
26. x≠y?
27. GTO H
28. 6
29. RTN
1. LBL H
2. R↓
3. RTN
Uses the sub-programme V:
Takes a real integer from the stack & stores remainder on division by 5 in R & quotient in Q & returns Q to stack, leaving Y, Z & T stack levels unaltered.
Code:
1. LBL V
2. R↑
3. STO J
4. R↓
5. STO R
6. 5
7. RMDR
8. x<>R
9. 5
10. INT/
11. R↑
12. X<>J
13. R↓
14. STO Q
15. RTN