SpiralFlex
Well-Known Member
- Joined
- Dec 18, 2010
- Messages
- 6,960
- Gender
- Female
- HSC
- N/A
With Sy's solution you're essentially searching the array twice one for value/index value. Since the array is pretty large this is undesirable.Hello all,
Also, is there perhaps a way to make my program more efficient? Technical or Mathematical?
Also iterate two if statements aren't necessary, either n is even or odd so check one you can check one only.
Code:
public int iterate(int n){
if (n%2 == 0){
return n/2;
}
return 3*n+1;
}
Last edited: