Skip to content

Conversation

@manoflearning
Copy link
Owner

No description provided.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 8 to 13
for (auto &p : prime) {
ll v = 1LL * p * i;
if (v > n) break;
lp[v] = p;
if (lp[i] = p) { mu[v] = 0; break; }
else mu[v] = -mu[i];

Choose a reason for hiding this comment

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

P1 Badge Fix Möbius sieve’s prime-multiple branch

The inner loop assigns lp[i] = p and immediately treats the branch as true. Because this is an assignment rather than a check on whether i is divisible by p, every iteration forces lp[i] to the current prime, mu[v] becomes 0, and the loop breaks. As a result, the function returns 0 for almost every value and never produces the correct ±1 Möbius values for square‑free integers. The conditional should test divisibility (i % p == 0) or compare against the least prime factor, instead of assigning.

Useful? React with 👍 / 👎.

@manoflearning manoflearning merged commit bb14f16 into master Oct 24, 2025
1 check passed
@manoflearning manoflearning deleted the mobius branch October 24, 2025 08:10
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.

2 participants