Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

###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.

Source Link
Caridorc
  • 28k
  • 7
  • 54
  • 137

###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

AltStyle によって変換されたページ (->オリジナル) /