Toggle navigation shitcode
  • Latest
  • Browse
  • Top
  • Worst
  • Add
  • All 496
  • ActionScript 3
  • Bash 7
  • Brainfuck 1
  • LSL 21
  • C++ 35
  • C# 54
  • CSS 5
  • Pascal 1
  • Django 1
  • Erlang 1
  • GLSL 1
  • Go 7
  • Groovy 1
  • HTML 10
  • Java 76
  • JavaScript 105
  • Less 1
  • Lua 3
  • Nix 1
  • Obj-C 4
  • OCaml 1
  • Perl 1
  • PHP 74
  • PowerShell 1
  • Python 46
  • Ruby 3
  • Rust 2
  • Scala 3
  • SQL 7
  • Swift 4
  • TypeScript 13
  • VBScript 2
  • Verilog 1
#2655 "Even number" Ruby -178
def even?(number)
  if number > 0
    result = number
  else
    result = -number
  end

  while result > 2 or result == 2
    result = result - 2
  end

  if result == 0
    true
  else
    false
  end
end

Best solution to find out if a number is even.

Comments
By Anonymous, 2023-11-12 14:59:07
  • «
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • »

© Shitcode.net 2026, Powered by Yii Framework

GitHub • About • Admin