I want to create a function (or anything, really) that is capable of calling its own logic.
The idea is as follows:
Funccall[a_,b_,n_]:=
For[i=1,i<=n,i++,{Return[i*(4+i/3)*Funccall[a,b,n-1];}
or something like that. Not the exact function; it's too long. How do i achieve this effect?
Edit
Here's the purpose of the code: to generate all products from a matrix from elements which dont share rows or columns
For[i in n, for j in n, for k in in [This goes on till n times i.e. n for loops]
if j!=i && k!=i &&k!=j &&.....->Multiply[a1i,a2j,a3k,a4l..........]
I need a function to do this.
The If
condition I've implemented by creating an empty array used
that stores whatever numbers have been used, and then I use FreeQ[used, k]
.
I hope this gives some clarity.
f[0] = 1; f[x_] := x f[x - 1];
Factorial implemented recursively. Generally usingFor
andReturn
are not the best use of Mathematica's capabilities. This may be an X-Y problem, what are you actually trying to accomplish? $\endgroup$