7 kyu
Halving Sum
5,013 of 12,849Belia
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
COBOL translation.
approved
Ruby 3.0 should be enabled, see this to learn how to do it
Please organize the structure of test fixture as following (although it has been mentioned in the attached link, I'm repeated here again)
fixed
This comment has been hidden.
This comment has been hidden.
You need to calculate the infinite sum (first term is n, each following term is the previous term integer-divided by 2), not just the sum of the first five terms.
Dart translation
Approved
This comment has been hidden.
Nobody's going to invalidate all solutions to test some arbitrary value.
I submitted a solution with a different signature and it works. For correctness then the instructions should indicate a max value for the expected input. Otherwise the solutions, from a production grade point of view, are incorrect.
PHP translation
When halving should we be rounding up, down, or to the closest integer?
Just typecast it to an integer and it should take care of it for you, depending on which language you're using
Ace, thanks!
CoffeeScript translation
Man if this wasn't using integer division it would have been a one liner...
( Depending on your language ) It still is.
Thanks for this kata. I think it would be a good kata if the input integer could be anything other than positive. Especially for JavaScript, because JS doesn't have native method for integer division, but the "floor" method rounds negative integers in a non-obvious way (Math.floor(-99.01) == -100).
Nobody's going to change the requirements now.
Haskell translation
C++ translation. Please, review and approve.
C translation. Please, review and approve.
Why should 72 equal 73?
There is no fixed test in Python expecting that result, so it was a random test. Print the input to know what it is, your code was off by one.
Thank you. Solved!
Ruby translation kumited -- please check and approve (note: author is inactive)
python translation:
https://www.codewars.com/kumite/5e9421558f65e7002457e94a?sel=5e9421558f65e7002457e94a
This comment has been hidden.
Yep, it's easy to overlook.
Fixed