Skip to content

Create 50. Pow(x, n).md#17

Merged
Mike0121 merged 1 commit into46.-Permutationsfrom
50.-Pow(x,-n)
Nov 1, 2025
Merged

Create 50. Pow(x, n).md#17
Mike0121 merged 1 commit into46.-Permutationsfrom
50.-Pow(x,-n)

Conversation

@Mike0121
Copy link
Copy Markdown
Owner

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

これfloatキャストしているのは何ででしょう。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

認知負荷が高いと感じます。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

x ** n はもともと float 型だと思いますので、 float() で囲わなくてよいと思います。

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 self.myPow(1.0 / x, -n) とすることで、この行をシンプルにできると思います。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

関数が float を返していますので、整数の 1 ではなく float の 1.0 を返したほうが自然だと思います。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

/ の両隣には空白を空けましょう。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

divided_prod は変数名の意味が分かりませんでした。変数に含まれる値の意味を、日本語で説明してみていただけますか?

@Mike0121 Mike0121 merged commit eddbe85 into 46.-Permutations Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants