You have succumbed to mental confusion caused by using the same names for variables in main and in zeroORone.
When you call zeroORone on line 8, you save the return value in ans. However, when you call the function recursively in line 32, you throw the return value away. Within this function, the variable result is local to the current recursion level and is destroyed when that level returns to the next higher level.
Lets call main level 0 and prefix its variables with L0::. L0::result is initialized to 1. line 8 passes this value to zeroORone at level 1. L1::Num1 is computed as 1 etc and line 32 passes L1::result to level 2. L2::num1 is computed as 2 etc and line 32 passes L2:result to level 3. L3::num1 is computed as 3 etc and line 25 sets L3::result to 0. line 34 prints L3::result and line 35 returns it to level 2 where it is promptly discarded. L2::result is still 1. Line 34 prints L2::result and line 35 returns it to level 1 where it is also discarded. L1::result is still 1. Line 34 prints L1::result and line 35 returns it to level 0 (main) where it is saved in ans. But as noted two sentences prior, the returned value is L1::result which was never changed from 1.
When level n+1 returns a value, you must save that value so level n can in turn return that value back to level n-1.