-
MathematicsAlgorithmsLogicNumbersFundamentalsData Types
Code def compute(n): return sum(x for x in range(n) if (x % 3 == 0 or x % 5 == 0))
Test Cases Test.describe("Basic tests") Test.assert_equals(compute(1000), 233168) Test.assert_equals(compute(48237), 542917083) Test.assert_equals(compute(1928), 866894) Test.assert_equals(compute(758), 133889) # test.assert_equals(actual, expected, [optional] message) # test.assert_not_equals(actual, expected, [optional] message) # You can use Test.describe and Test.it to write BDD style test groupings
Output:
-
Code - def compute(n):
ans = sum(x for x in range(n) if (x % 3 == 0 or x % 5 == 0))return ans- return sum(x for x in range(n) if (x % 3 == 0 or x % 5 == 0))
- 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 }}