Skip to content

Instantly share code, notes, and snippets.

@egeulgen
Last active November 9, 2023 17:16
Show Gist options
  • Save egeulgen/01470bf5a63bd1c3ef643f323abf8852 to your computer and use it in GitHub Desktop.
Save egeulgen/01470bf5a63bd1c3ef643f323abf8852 to your computer and use it in GitHub Desktop.
Returns all (positive and negative) factors of the given number
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