1 Pages (16 items)
Recursion in SMath - Can we use recursion in SMath? - Messages
#1 Posted: 10/24/2023 1:28:09 PM
#2 Posted: 10/24/2023 2:53:19 PM
Yes, recursion is possible. Although I don't remember how many levels are allowed.
Here is your example in an smath file.
Fibo_recursion_example.sm (3 KiB) downloaded 27 time(s).
Here is your example in an smath file.
Fibo_recursion_example.sm (3 KiB) downloaded 27 time(s).
1 users liked this post
Valery Ochkov 10/24/2023 4:48:00 PM
#3 Posted: 10/24/2023 5:13:18 PM
WroteYes, recursion is possible. Although I don't remember how many levels are allowed.
Here is your example in an smath file.
Fibo_recursion_example.sm (3 KiB) downloaded 27 time(s).
Thanks! But I think it was not from me but from SMath error!
And the second!
Why 0!=1?
See
Factorial.sm (4 KiB) downloaded 26 time(s).
#4 Posted: 10/24/2023 6:23:19 PM
Here is the corrected Fibo recursive function...
Fibo_recursion_corrected.sm (4 KiB) downloaded 30 time(s).
As for 0!=1 the following page gives two explanations.
https://zero-factorial.com/whatis.html
Fibo_recursion_corrected.sm (4 KiB) downloaded 30 time(s).
As for 0!=1 the following page gives two explanations.
https://zero-factorial.com/whatis.html
#5 Posted: 10/24/2023 8:21:01 PM
Here is a more streamlined version...

1 users liked this post
Valery Ochkov 10/24/2023 8:50:00 PM
#6 Posted: 10/24/2023 8:49:36 PM
WroteHere is a more streamlined version...
Thanks!
And what about
https://en.wikipedia.org/wiki/Ackermann_function
#7 Posted: 10/24/2023 9:16:47 PM
This seems to work for the Ackermann function...

Ackermann function.sm (4 KiB) downloaded 28 time(s).
Ackermann function.sm (4 KiB) downloaded 28 time(s).
1 users liked this post
Valery Ochkov 10/24/2023 10:08:00 PM
#8 Posted: 10/25/2023 8:32:50 PM
WroteYes, recursion is possible. Although I don't remember how many levels are allowed.
Typical, factorial(n) command-line is limited ...factorial(40)
1 users liked this post
Valery Ochkov 10/25/2023 8:46:00 PM
#9 Posted: 10/25/2023 9:08:48 PM
WroteOriginally Posted by: Gerry_Bush [url=/forum/yaf_postsm82817_Recursion-in-SMath.aspx#post82817][/url]Yes, recursion is possible. Although I don't remember how many levels are allowed.
Typical, factorial(n) command-line is limited ...factorial(40)
By same token, Fibonacci(n) command-line upper limit
Fibonacci(1473) ... 1.9069*10^307 ... Windows limit.
1 users liked this post
Valery Ochkov 10/26/2023 12:49:00 AM
#11 Posted: 10/25/2023 10:37:39 PM
4 users liked this post
ioan92 10/26/2023 12:28:00 AM, Valery Ochkov 10/25/2023 11:27:00 PM, NDTM Amarasekera 10/25/2023 11:53:00 PM, Oscar Campo 10/26/2023 4:39:00 PM
#12 Posted: 10/26/2023 12:33:28 AM
WroteTypical, factorial(n) command-line is limited ...factorial(40)
The vectorized version n 170 ... 7.2574*10^306
1 users liked this post
Valery Ochkov 10/26/2023 12:49:00 AM
#13 Posted: 10/26/2023 2:00:47 AM
#15 Posted: 10/26/2023 4:07:27 AM
Valery, Smath Gamma(x) is known 4 decimals.
Reported years ago, ignored.
Alvaro Gamma(x) 15 decimals
Reported years ago, ignored.
Alvaro Gamma(x) 15 decimals
#16 Posted: 10/26/2023 9:07:36 AM
Wrote... And what about
https://en.wikipedia.org/wiki/Ackermann_function
Ackermann function is not 'primitive recursive', which means that it can't be computed only with for loops. Here an iterative implementation with a stack and no recursion.
Ackermann-Iterative.sm (8 KiB) downloaded 23 time(s).
Best regards.
Alvaro.
2 users liked this post
1 Pages (16 items)
-
New Posts
-
No New Posts