Stop a formula if a certain value is returned. I'm playing around with the Collatz conjecture, where given an integer number, if it is even, divide it by 2, and if it is odd, multiply by 3 and add 1. The conjecture states that any integer number will eventually end up at 1. 

I am wanting to count the steps taken from any integer to reach 1.

So far I have the formula =IF(MOD(A1,2)=0,A1/2,(A1*3)+1) where a given integer is in cell A1, and this works fine. This is in cell A2 so the formula repeats itself on the new integer that is produced.

However I want the formula to stop when the integer sequence hits 1 for the first time (otherwise it repeats this sequence ... 1, 4, 2, 1, 4, 2, 1, ...

Then I will be able to use the count function to count the number of steps taken to get to 1.

Any suggestions will be appreciated.