GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Java/Maths/PowRecursion.java at master · tmluwei/Java Expand file tree/ Copy pathPowRecursion.javaMore file actions 21 lines (19 loc) · 633 Bytes / Copy pathPowRecursion.javaFile metadata and controls21 lines (19 loc) · 633 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 package Maths; public class PowRecursion { public static void main(String[] args) { assert Double.compare(pow(2, 0), Math.pow(2, 0)) == 0; assert Double.compare(pow(0, 2), Math.pow(0, 2)) == 0; assert Double.compare(pow(2, 10), Math.pow(2, 10)) == 0; assert Double.compare(pow(10, 2), Math.pow(10, 2)) == 0; } /** * Returns the value of the first argument raised to the power of the second argument * * @param a the base. * @param b the exponent. * @return the value {@code a}<sup>{@code b}</sup>. */ public static long pow(int a, int b) { return b == 0 ? 1 : a * pow(a, b - 1); } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |