Was asked for an algorithm to reverse integers, given 123 output would be 321. Cannot use string or char methods.
Anonymous
public int reverse(int x) { int rev = 0; while(x != 0){ rev = rev*10 + x%10; x = x/10; } return rev; }
Check out your Company Bowl for anonymous work chats.