Skip to content

50. Pow(x, n) - #40

Open
akmhmgc wants to merge 1 commit into
mainfrom
50
Open

50. Pow(x, n)#40
akmhmgc wants to merge 1 commit into
mainfrom
50

Conversation

@akmhmgc

@akmhmgc akmhmgc commented Oct 3, 2025

Copy link
Copy Markdown
Owner

解いた問題

50. Pow(x, n)

使用言語

Ruby

次に解く問題

https://leetcode.com/problems/k-th-symbol-in-grammar/

@akmhmgc akmhmgc added the ruby label Oct 3, 2025
Comment thread 50/step3.md
if exponent.even?
return my_pow(base, exponent / 2) ** 2
else
return base * my_pow(base, exponent - 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

趣味の範囲ですが、
return base * my_pow(base, exponent / 2) ** 2
としても良いかなと思いました。

Comment thread 50/step1.md
else
result /= calculate_my_pow.call(exsp_left)
result /= calculate_my_pow.call(exsp_right)
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文脈によっては二項演算子の左右を lhs, rhs と書くと伝わることがあると思いました。その場合は *= ではなく
result = calculate_my_pow.call(exsp_left) * calculate_my_pow.call(exsp_right)
と書いたらわかりやすそうです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants