You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to define a function like "prime number integer factorization".
Example: decomp(15) would return [3,5] ; decomp(61) would return [61].
As far as I understand, it's not possible for a user-defined function to return several values.
This issue is to suggest an evolution to support return multiple values, a list for instance.
Thanks.
The text was updated successfully, but these errors were encountered:
It is possible to return multiple values in i vector, but efficient implementation of factorization in a user-defined function would be difficult.
A function which returns all unique prime factors can be defined as follows.
Subfunction: process(if(\x%\p, 0, \p), \p, primes(\x/2))
Function: if(element(\1, 1)=0, \x, limits(\1, 1, sum(\p>0, 1, elements(\1))))
Considering that the above function is much less efficient (noticeable for value > 100000) than using "to factors" (e.g. 15 to factors returns 3 × 5), and that you are not the first to ask for it, I will add a prime factors function (in code).
Hello,
I'd like to define a function like "prime number integer factorization".
Example: decomp(15) would return [3,5] ; decomp(61) would return [61].
As far as I understand, it's not possible for a user-defined function to return several values.
This issue is to suggest an evolution to support return multiple values, a list for instance.
Thanks.
The text was updated successfully, but these errors were encountered: