Skip to content
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

Create different_power_of2.js #523

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/algorithms/math/is-power-of-two/different_power_of2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

// different power of 2 requiered so that the sum of different power of 2 equals to no..

Choose a reason for hiding this comment

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

typo here - requiered (sic) should be required

Copy link
Author

Choose a reason for hiding this comment

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

Can you please help me. What is sis why i am getting the error.

Choose a reason for hiding this comment

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

"Sic" is meant to indicate that there's a typo without fixing it.

Not sure on the error 😅

https://www.merriam-webster.com/words-at-play/sic-meaning-usage-editorial-citation

export default function diffPowerOfTwo(number) {
if (number < 1) {
return 0;
}
var a=0;
let dividedNumber = number;
while (dividedNumber !== 1) {
if (dividedNumber % 2 !== 0) {
a+=1;
}
a+=1;

dividedNumber /= 2;
}

return a;
}