Mathematics
Algorithms
Logic
Numbers
function prime_checker (n) { if (n === 1 || n === 0) return false; for(let i = 2; i < n; i++) { if(n % i === 0) return false; } return true; }
import mathdef prime_checker(n):if n == 1:return Falsemax_divisor = math.floor(math.sqrt(n))for d in range(2, 1 + max_divisor):if n % d == 0:return Falsereturn True- function prime_checker (n) {
- if (n === 1 || n === 0) return false;
- for(let i = 2; i < n; i++) {
- if(n % i === 0) return false;
- }
- return true;
- }
const chai = require("chai"); const assert = chai.assert; chai.config.truncateThreshold=0; describe("Example", function(){ it("test case", function(){ assert.strictEqual(prime_checker(653), true); assert.strictEqual(prime_checker(654), false); assert.strictEqual(prime_checker(5), true); assert.strictEqual(prime_checker(777), false); assert.strictEqual(prime_checker(977), true); assert.strictEqual(prime_checker(125), false); assert.strictEqual(prime_checker(997), true); assert.strictEqual(prime_checker(709), true); assert.strictEqual(prime_checker(15), false); assert.strictEqual(prime_checker(1), false); assert.strictEqual(prime_checker(0), false); }); });
import codewars_test as testfrom solution import prime_checker- const chai = require("chai");
- const assert = chai.assert;
- chai.config.truncateThreshold=0;
@test.describe("Example")def test_group():@test.it("test case")def test_case():test.assert_equals(prime_checker(653), True)test.assert_equals(prime_checker(654), False)test.assert_equals(prime_checker(5), True)test.assert_equals(prime_checker(777), False)test.assert_equals(prime_checker(977), True)test.assert_equals(prime_checker(125), False)test.assert_equals(prime_checker(997), True)test.assert_equals(prime_checker(709), True)test.assert_equals(prime_checker(15), False)- describe("Example", function(){
- it("test case", function(){
- assert.strictEqual(prime_checker(653), true);
- assert.strictEqual(prime_checker(654), false);
- assert.strictEqual(prime_checker(5), true);
- assert.strictEqual(prime_checker(777), false);
- assert.strictEqual(prime_checker(977), true);
- assert.strictEqual(prime_checker(125), false);
- assert.strictEqual(prime_checker(997), true);
- assert.strictEqual(prime_checker(709), true);
- assert.strictEqual(prime_checker(15), false);
- assert.strictEqual(prime_checker(1), false);
- assert.strictEqual(prime_checker(0), false);
- });
- });
def Hello_Python(a='Hello',b='Python!'): return a + b
System.Console.WriteLine("Hello, C#!");- def Hello_Python(a='Hello',b='Python!'):
- return a + b
import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals('Hello ' + 'Python!', 'Hello Python!')
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- test.assert_equals('Hello ' + 'Python!', 'Hello Python!')
def add(a=0,b=0): return float(abs(a) + abs(b))
def add(a, b):return (a**2-b**2)//(a-b)- def add(a=0,b=0):
- return float(abs(a) + abs(b))
import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(add(1,1), 2) test.assert_equals(add(-100,100), 200) test.assert_equals(add(512.96,475.04), 988) test.assert_equals(add(0,0), 0) test.assert_equals(add(), 0) test.assert_equals(add(-10.5,1), 11.5) test.assert_equals(add(-1096,-200), 1296) test.assert_equals(add(-9549), 9549) test.assert_equals(add(34.999,0.001), 35.0) test.assert_equals(add(101,-2.3256), 103.3256)
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- test.assert_equals(add(1,1), 2)
- test.assert_equals(add(-100,100), 200)
- test.assert_equals(add(512.96,475.04), 988)
- test.assert_equals(add(0,0), 0)
- test.assert_equals(add(), 0)
- test.assert_equals(add(-10.5,1), 11.5)
- test.assert_equals(add(-1096,-200), 1296)
- test.assert_equals(add(-9549), 9549)
- test.assert_equals(add(34.999,0.001), 35.0)
- test.assert_equals(add(101,-2.3256), 103.3256)