Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Optimize power() using exponentiation by squaring (O(log n))#7069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Vinayak-v12 wants to merge3 commits intoTheAlgorithms:master
base:master
Choose a base branch
Loading
fromVinayak-v12:optimize-power-method
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
Fix formatting issues reported by clang-format
  • Loading branch information
@Vinayak-v12
Vinayak-v12 committedNov 15, 2025
commit053744205f1c2fe469dcdce3460668beb1ceec88
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,6 @@ private PowerUsingRecursion() {
* @param exponent the power (can be negative)
* @return base^exponent
*/

public static double power(double base, int exponent) {

// Handle negative exponent: a^-n = 1 / (a^n)
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,5 +25,4 @@ void testPowerUsingRecursion() {
// another negative exponent
assertEquals(0.5, PowerUsingRecursion.power(2.0, -1));
}

}

[8]ページ先頭

©2009-2025 Movatter.jp