I'm presenting an internal workshop to the team on iterative macros using the Collatz Conjecture as a use case where every number reduces to 1 by applying two conditional functions: if odd 3n+1, if even n/2. As an example, 79 reduces to 1 in 35 iterations when just one value runs through the macro. But, when several values, including 79, run through, the number of iterations increases. How do I get the engine.iterationnumber constant to reset to zero?
Sorry, I can't upload an image or a file due to our network settings, but it's a simple iterative macro:
Input -> Filter(Mod(n,2))->Formula from T(n*3+1), Formula from F(n/2) -> Union -> Filter(n=1) -> Formula from T(engine.iterationnumber+1) -> Results output, then iteration output from F.
This works perfectly for just one number through the input. I then have an app that allows the user to select a range of integers that are fed into the macro. If it's just a few numbers, like 77-80, the results are accurate. But, if it's 27-80, it shows that 79 reduces to 1 in 112 iterations. Amp Engine is turned off for both the macro and the app. Alone, 70 reduces in 14 iterations, as part of a range, in 35 iterations.
Should I make this a nested iterative macro? A Batch macro nesting the iterative? This looks like a bug of some sort. Or is there a way to reset the constant as each number is received?
Thanks!!
Joy