-
-
Notifications
You must be signed in to change notification settings - Fork 157
Solution next happy number added #400
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
Solution next happy number added #400
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Here's the code health analysis summary for commits Analysis Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change code based on suggestions for good practices
Since we have already reached 1, the process stops here. 1 is a happy number. | ||
|
||
- **Number 2:** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad Practice:
```
$[2^2 = 4]$
$[4^2 = 16]$
$[1^2 + 6^2 = 37]$
$[3^2 + 7^2 = 58]$
$[5^2 + 8^2 = 89]$
$[8^2 + 9^2 = 145]$
$[1^2 + 4^2 + 5^2 = 42]$
$[4^2 + 2^2 = 20]$
$[2^2 + 0^2 = 4]$
Since we have reached 4 again, the process will continue in an infinite loop. 2 is not a happy number.
```
Good Practice
$[2^2 = 4]$
$[4^2 = 16]$
$[1^2 + 6^2 = 37]$
$[3^2 + 7^2 = 58]$
$[5^2 + 8^2 = 89]$
$[8^2 + 9^2 = 145]$
$[1^2 + 4^2 + 5^2 = 42]$
$[4^2 + 2^2 = 20]$
$[2^2 + 0^2 = 4]$
Since we have reached 4 again, the process will continue in an infinite loop. 2 is not a happy number.
|
||
- **Number 7:** | ||
|
||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad Practice:
```
$[7^2 = 49]$
$[4^2 + 9^2 = 97]$
$[9^2 + 7^2 = 130]$
$[1^2 + 3^2 + 0^2 = 10]$
$[1^2 + 0^2 = 1]$
Since we have reached 1, the process stops here. 7 is a happy number.
```
Good Practice
$[7^2 = 49]$
$[4^2 + 9^2 = 97]$
$[9^2 + 7^2 = 130]$
$[1^2 + 3^2 + 0^2 = 10]$
$[1^2 + 0^2 = 1]$
Since we have reached 1, the process stops here. 7 is a happy number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change code based on suggestions
|
||
## Problem Description | ||
|
||
Given a positive number N, find the value of f0 + f1 + f2 + ... + fN where fi indicates the ith Fibonacci number. Note that f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5, and so on. Since the answer can be very large, return the result modulo 1000000007. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace f0 + f1 + f2 + ... + fN
to $f0 + f1 + f2 + ... + fN$
f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5,
to $f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5,$
and 1000000007
to $1000000007$
|
||
## Constraints | ||
|
||
1. $(1 \leq N \leq 10^5)$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace 1. $(1 \leq N \leq 10^5)$
to - $(1 \leq N \leq 10^5)$
hey @ajay-dhangar , i updated as per your suggestion , you can merge it |
|
hey @ajay-dhangar , what is this issue/problem? i did not get it |
@Vipullakum007 First, you need to run |
Related Issue
i want to add solution of "next happy number " problem #389
fixes : #389
Description
i have added solution of "next happy number " problem
Type of PR
Screenshots / Videos (if applicable)
NextHappyNumber.mp4
Checklist
Additional Context
[Include any additional information or context that might be helpful for reviewers.]
Resources for Guidance
Here are some resources that may be helpful as you contribute to CodeHarborHub:
Resources for DSA Features on Our Site: