@@ -0,0 +1,1308 @@
+package main.algorithm.a.jian.zhi.offer;%0A%0Aimport static java.lang.System.out;%0A%0A/**%0A * Title : main.algorithm.a.jian.zhi.offer %3Cbr%3E%0A * Description :%0A *  %3Cp%3E%0A *  %3Cul%3E %0A *      %3Cli%3E%0A *  %3C/ul%3E%0A * @author chile%0A * @version 1.0%0A * @date 2018/5/11 10:16%0A */%0Apublic class FastPower %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        standard(5, 5);%0A        fastPower(5, 5);%0A%0A        standard(5, 6);%0A        fastPower(5, 6);%0A    %7D%0A%0A    /**%0A     * time complexity : O(n)%0A     * @param base   base number%0A     * @param power  power number%0A     */%0A    private static void standard(int base, int power) %7B%0A        int result = 1, tempPower = power;%0A        while (tempPower %3E 0) %7B%0A            result *= base;%0A            tempPower--;%0A        %7D%0A        out.println(base + %22%5E%22 + power + %22=%22 + result);%0A    %7D%0A%0A    /**%0A     * fast power%0A     * time complexity : O(log n)%0A     * @param base  base number%0A     * @param power power number%0A     */%0A    private static void fastPower(int base, int power) %7B%0A        int result = 1, tempPower = power, tempBase = base;%0A        while (tempPower %3E 0) %7B%0A            if ((tempPower & 1) == 1) %7B%0A                result *= tempBase;%0A            %7D%0A            tempPower %3E%3E= 1;%0A            tempBase *= tempBase;%0A        %7D%0A        out.println(base + %22%5E%22 + power + %22=%22 + result);%0A    %7D%0A%0A%7D%0A

fast power