-
Code unsigned long long div2(unsigned long long a) { long long i = 0; while (a>=2){ a -= 2; i++; } return i; }
Test Cases // TODO: Replace examples and use TDD by writing your own tests Describe(d2) { It(under10) { Assert::That(div2(10), Equals(5)); Assert::That(div2(0), Equals(0)); Assert::That(div2(3), Equals(1)); } It(huge_numbers) { Assert::That(div2(65536), Equals(32768)); Assert::That(div2(6553665535), Equals(3276832767)); Assert::That(div2(1234567890), Equals(617283945)); } };
Output:
-
Code - unsigned long long div2(unsigned long long a) {
- long long i = 0;
- while (a>=2){
a = a-2;- a -= 2;
- i++;
- }
- return i;
- }
- All
- {{group.name}} ({{group.count}})
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
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}