Last active
November 9, 2023 17:16
-
-
Save egeulgen/01470bf5a63bd1c3ef643f323abf8852 to your computer and use it in GitHub Desktop.
Returns all (positive and negative) factors of the given number
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
FUN <- function(x) { | |
x <- as.integer(x) | |
div <- seq_len(abs(x)) | |
factors <- div[x %% div == 0L] | |
factors <- list(neg = -factors, pos = factors) | |
return(factors) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment