-
Notifications
You must be signed in to change notification settings - Fork 77
CPP: add Happy Number solution (IEEEXtreme style) #215
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
🎉 Welcome to Hacktoberfest 2025, @Mojirade18! 🎃 Thank you for your first contribution to our DSA repository! Here's what happens next: 🔍 Automatic Checks
📋 Next Steps🎁 What You Get
💡 Tips for Success
Welcome to the community! 🚀 |
🤖 Automated PR Status🔍 Code Validation✅ Passed - File naming and structure look good! 🧪 Compilation Tests❌ Failed - Please fix compilation errors and try again. 📋 Overall Status
This comment was generated automatically. Checks will re-run when you push new commits. |
|
🎉 Welcome to Hacktoberfest 2025, @Mojirade18! 🎃 Thank you for your first contribution to our DSA repository! Here's what happens next: 🔍 Automatic Checks
📋 Next Steps🎁 What You Get
💡 Tips for Success
Welcome to the community! 🚀 |
🤖 Automated PR Status🔍 Code Validation✅ Passed - File naming and structure look good! 🧪 Compilation Tests❌ Failed - Please fix compilation errors and try again. 📋 Overall Status
This comment was generated automatically. Checks will re-run when you push new commits. |
|
🎉 Welcome to Hacktoberfest 2025, @Mojirade18! 🎃 Thank you for your first contribution to our DSA repository! Here's what happens next: 🔍 Automatic Checks
📋 Next Steps🎯 Great job! Your code compiled successfully. Maintainers @admirerr and @kartikey2991 will review your PR soon. 🎁 What You Get
💡 Tips for Success
Welcome to the community! 🚀 |
🤖 Automated PR Status🔍 Code Validation✅ Passed - File naming and structure look good! 🧪 Compilation Tests✅ Passed - All code compiles successfully! 📋 Overall Status🎉 Ready for Review - Your PR has passed all automated checks! This comment was generated automatically. Checks will re-run when you push new commits. |
|
🎉 Welcome to Hacktoberfest 2025, @Mojirade18! 🎃 Thank you for your first contribution to our DSA repository! Here's what happens next: 🔍 Automatic Checks
📋 Next Steps🎯 Great job! Your code compiled successfully. Maintainers @admirerr and @kartikey2991 will review your PR soon. 🎁 What You Get
💡 Tips for Success
Welcome to the community! 🚀 |
🤖 Automated PR Status🔍 Code Validation✅ Passed - File naming and structure look good! 🧪 Compilation Tests✅ Passed - All code compiles successfully! 📋 Overall Status🎉 Ready for Review - Your PR has passed all automated checks! This comment was generated automatically. Checks will re-run when you push new commits. |
|
Approved |
Problem Name: Happy Number
Category: Basics (Mathematics / Number Manipulation)
Language: C++
Description
A Happy Number is a number that eventually reaches 1 when replaced by the sum of the squares of its digits repeatedly.
If the process enters a cycle that does not include 1, the number is not happy.
This solution implements the Floyd’s Cycle Detection Algorithm to determine if a number is happy or not.
Input / Output
Input:
A single positive integer n.
Output:
Prints "YES" if n is a happy number, otherwise prints "NO".
Example:
Input:
19
Output:
YES
Approach
Compute the sum of squares of digits.
Use two pointers (tortoise & hare) to detect loops efficiently.
If the sequence reaches 1 → happy number.
If it enters a loop → not happy.
File Information
File Path: CPP/Basics/happy_number.cpp