0
0

More than 1 year has passed since last update.

【Ruby】奇数か偶数かを判断するメソッド

Posted at
  • Inetger#odd?は奇数であればtrue、そうでなければfalseを返します。
  • Inetger#even?は偶数であればtrue、そうでなければfalseを返します。

奇数かどうか

5.odd? =>  true
10.odd? => false

偶数かどうか

10.even? => true
5.even? => false
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0