Ad

Desing an algorithm that accepts a positive integer and reverses the order of its digits.

public class Algorithms {
  public static int reverseInt(int n) {
    int reversed = 0;
    
    while(n != 0){
      reversed = reversed * 10 + (n % 10);
      n /= 10;
    }
    
    return reversed;
  }
}