Created
March 30, 2021 22:05
-
-
Save ricealexander/b053f126c90637c1d1d94cc35bcf19ae to your computer and use it in GitHub Desktop.
Returns an array of all fractions of N
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getFractions (n) { | |
return Array.from({length}, (_, index) => (index + 1) / n) | |
} | |
// Example, all fractions of 16 (1/16, 2/16, 3/16, 4/16...) | |
getFractions(16) // [0.0625, 0.125, 0.1875, 0.25, 0.3125, 0.375, 0.4375, 0.5, 0.5625, 0.625, 0.6875, 0.75, 0.8125, 0.875, 0.9375, 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment