Tag Info

Hot answers tagged


Never use pattern matching unless you absolutely have to. Using Cases instead of Select can make a huge difference. Vectorize operations. Use Range instead of Table if you can. Test several things at once. And[test1, test2, test3] will abort when it can for maximum efficiency ("short circuit evaluation"). Taking this into consideration your code looks ...


As I mentioned in my comment, of course Mathematica has a built-in function to calculate the GCD, called GCD (docs). My understanding, however, is that you are using the GCD as an example to learn how to apply a function recursively for a number of times that is not decided a priori, but that depends on the inputs and the path of the calculation. The ...

Only top voted, non community-wiki answers of a minimum length are eligible