Skip to content

Instantly share code, notes, and snippets.

@knugie
Created September 2, 2018 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knugie/b9a6dd1faf9fd6c3ade4e4022818ce2b to your computer and use it in GitHub Desktop.
Save knugie/b9a6dd1faf9fd6c3ade4e4022818ce2b to your computer and use it in GitHub Desktop.
How many 3 digit numbers have exactly 3 factors?
[*100..999].count{ |x| (1..x).count { |i| x % i == 0 } == 3 }
# => 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment