Fundamentals
Numbers
Data Types
Integers
class Odd def odd(n) n % 2 == 1 end end
public static class Kata{public static bool IsOdd(int input){return ((input % 10 == 1) || (input % 10 == 3) || (input % 10 == 5) || (input % 10 == 7) || (input % 10 == 9));}}- class Odd
- def odd(n)
- n % 2 == 1
- end
- end
describe Odd do it 'should return false if number is even' do expect(subject.odd(2)).to eq(false) expect(subject.odd(16)).to eq(false) expect(subject.odd(19482475932)).to eq(false) end it 'should return true if number is odd' do expect(subject.odd(3)).to eq(true) expect(subject.odd(15)).to eq(true) expect(subject.odd(18409270457)).to eq(true) end end
namespace Solution {using NUnit.Framework;using System;// TODO: Replace examples and use TDD by writing your own tests[TestFixture]public class SolutionTest{[Test]public void MyTest(){Assert.AreEqual(true, Kata.IsOdd(1));Assert.AreEqual(false, Kata.IsOdd(2));Assert.AreEqual(true, Kata.IsOdd(13));Assert.AreEqual(false, Kata.IsOdd(18284));}}}- describe Odd do
- it 'should return false if number is even' do
- expect(subject.odd(2)).to eq(false)
- expect(subject.odd(16)).to eq(false)
- expect(subject.odd(19482475932)).to eq(false)
- end
- it 'should return true if number is odd' do
- expect(subject.odd(3)).to eq(true)
- expect(subject.odd(15)).to eq(true)
- expect(subject.odd(18409270457)).to eq(true)
- end
- end