Time and space complexity of this program

minimum steps to one

it should be of the order N
log2(N)+log3(N)+N
so time complexity will be O(N);