Skip to content

Add O(1) optimized solution for Project Euler Problem 6 #hacktoberfest - #1485

Closed
KRiSHnA88H wants to merge 1 commit into
TheAlgorithms:masterfrom
KRiSHnA88H:add-o1-solution-problem-6
Closed

KRiSHnA88H wants to merge 1 commit into
TheAlgorithms:masterfrom
KRiSHnA88H:add-o1-solution-problem-6

Conversation

@KRiSHnA88H

Copy link
Copy Markdown

Description

This PR adds an O(1) optimized solution for Project Euler Problem 6 in C.
It uses the mathematical formulas:

  • Sum of squares = n(n+1)(2n+1)/6
  • Square of sum = (n(n+1)/2)^2

Changes

  • Added new file o(1)sol.c in project_euler/problem_6/
  • Provides a faster O(1) implementation compared to iterative methods
  • Included comments and example usage for better understanding

Example

Input:
100

Output:
25164150

Notes

  • Uses long long to avoid overflow for larger values of n
  • Code is well-documented to support educational use

Thank you for reviewing this contribution 🚀

@KRiSHnA88H KRiSHnA88H changed the title Add O(1) optimized solution for Project Euler Problem 6 Add O(1) optimized solution for Project Euler Problem 6 #hacktoberfest Oct 1, 2025
@KRiSHnA88H KRiSHnA88H closed this Oct 1, 2025
@KRiSHnA88H KRiSHnA88H reopened this Oct 1, 2025
@github-actions

github-actions Bot commented Nov 1, 2025

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the Stale label Nov 1, 2025
@github-actions

github-actions Bot commented Nov 9, 2025

Copy link
Copy Markdown
Contributor

Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions!

@github-actions github-actions Bot closed this Nov 9, 2025
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