###all
all
Your if can become:
if (2..20).all? {|d| x % d == 0}
To avoid repetition.
all
returns at the first false so this should be as fast as yours.
###all
Your if can become:
if (2..20).all? {|d| x % d == 0}
To avoid repetition.
all
returns at the first false so this should be as fast as yours.
all
Your if can become:
if (2..20).all? {|d| x % d == 0}
To avoid repetition.
all
returns at the first false so this should be as fast as yours.
lang-rb