/*
 * Copyright (C) 2014 Pedro Vicente Gómez Sánchez.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.pedrovgs.problem70;

/**
 * Given an integer passed as parameter, can you write a method to return the number equivalent to
 * the binary number with the reversed order?
 *
 * For example:
 *
 * Input = 5 = 101
 * Output = 5 = 101
 *
 * Input = 13 = 1101
 * Output = 11 = 1011
 *
 * @author Pedro Vicente Gómez Sánchez.
 */
public class ReverseOrderOfBinaryNumber {

}

@@ -991,10 +991,608 @@
 mber %7B%0A%0A
+  /**%0A   * Iterative algorithm to solve this problem. Shifting the input number until the value is equals%0A   * to zero and applying a simple mask we are going to create the reverted order binary number%0A   * using a constant complexity time in space terms O(1) and a linear complexity order in time%0A   * terms O(N) where N is equals to the number of digits of the input parameter into a binary%0A   * representation.%0A   */%0A  public int reverse(int number) %7B%0A    int result = 0;%0A    while (number != 0) %7B%0A      result %3C%3C= 1;%0A      result %7C= number & 1;%0A      number %3E%3E= 1;%0A    %7D%0A    return result;%0A  %7D%0A
 %7D%0A

Add solution to problem 70