GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — using recursion · pythonpeixun/Java@d11b734

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Maths
    • PowRecursion.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Maths/PowRecursion.java‎

Copy file name to clipboardExpand all lines: Maths/PowRecursion.java
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public static void main(String[] args) {
1717
* @return the value {@code a}<sup>{@code b}</sup>.
1818
*/
1919
public static long pow(int a, int b) {
20-
int result = 1;
21-
for (int i = 1; i <= b; i++) {
22-
result *= a;
20+
if (b == 0) {
21+
return 1;
22+
} else {
23+
return a * pow(a, b - 1);
2324
}
24-
return result;
2525
}
2626
}

0 commit comments

Comments
0 (0)
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.