const multiple3And5 = (number) => { let sum = 0; for(let i = 0; i < number; i++) { if(i % 3 == 0 || i % 5 == 0) sum += i; } return sum; }
package katafunc Multiple3And5(number int) int {- const multiple3And5 = (number) => {
- let sum = 0;
- for(let i = 0; i < number; i++) {
- if(i % 3 == 0 || i % 5 == 0) sum += i;
- }
- return sum;
- }
// Since Node 10, we're using Mocha. // You can use `chai` for assertions. const chai = require("chai"); const assert = chai.assert; // Uncomment the following line to disable truncating failure messages for deep equals, do: // chai.config.truncateThreshold = 0; // Since Node 12, we no longer include assertions from our deprecated custom test framework by default. // Uncomment the following to use the old assertions: // const Test = require("@codewars/test-compat"); describe("Solution", function() { it("should handle basic cases", function() { assert.strictEqual(multiple3And5(10), 23); assert.strictEqual(multiple3And5(20), 78); }); it("should handle basic cases", function() { assert.strictEqual(multiple3And5(0), 0); assert.strictEqual(multiple3And5(1), 0); }); it("should handle basic cases", function() { assert.strictEqual(multiple3And5(200), 9168); }); });
package kata_testimport (. "github.com/onsi/ginkgo". "github.com/onsi/gomega". "codewarrior/kata")var _ = Describe("Multiples of 3 and 5", func() {It("should handle basic cases", func() {Expect(Multiple3And5(10)).To(Equal(23))Expect(Multiple3And5(20)).To(Equal(78))})It("should handle zeroes", func() {Expect(Multiple3And5(0)).To(Equal(0))Expect(Multiple3And5(1)).To(Equal(0))})It("should handle large numbers", func() {Expect(Multiple3And5(200)).To(Equal(9168))})})- // Since Node 10, we're using Mocha.
- // You can use `chai` for assertions.
- const chai = require("chai");
- const assert = chai.assert;
- // Uncomment the following line to disable truncating failure messages for deep equals, do:
- // chai.config.truncateThreshold = 0;
- // Since Node 12, we no longer include assertions from our deprecated custom test framework by default.
- // Uncomment the following to use the old assertions:
- // const Test = require("@codewars/test-compat");
- describe("Solution", function() {
- it("should handle basic cases", function() {
- assert.strictEqual(multiple3And5(10), 23);
- assert.strictEqual(multiple3And5(20), 78);
- });
- it("should handle basic cases", function() {
- assert.strictEqual(multiple3And5(0), 0);
- assert.strictEqual(multiple3And5(1), 0);
- });
- it("should handle basic cases", function() {
- assert.strictEqual(multiple3And5(200), 9168);
- });
- });