Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6063311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:09:06+00:00 2026-05-23T09:09:06+00:00

My normal search foo is failing me. I’m trying to find an R function

  • 0

My normal search foo is failing me. I’m trying to find an R function that returns ALL of the factors of an integer. There are at least 2 packages with factorize() functions: gmp and conf.design, however these functions return only prime factors. I’d like a function that returns all factors.

Obviously searching for this is made difficult since R has a construct called factors which puts a lot of noise in the search.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:09:06+00:00Added an answer on May 23, 2026 at 9:09 am

    To follow up on my comment (thanks to @Ramnath for my typo), the brute force method seems to work reasonably well here on my 64 bit 8 gig machine:

    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)
    }
    

    A few examples:

    > FUN(100)
    $neg
    [1]   -1   -2   -4   -5  -10  -20  -25  -50 -100
    
    $pos
    [1]   1   2   4   5  10  20  25  50 100
    
    > FUN(-42)
    $neg
    [1]  -1  -2  -3  -6  -7 -14 -21 -42
    
    $pos
    [1]  1  2  3  6  7 14 21 42
    
    #and big number
    
    > system.time(FUN(1e8))
       user  system elapsed 
       1.95    0.18    2.14 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Solr for search. I have documents that have an integer field popularity
What's the best way implement MS SQL full-text search using all the normal things
I've done the breadth-first search in a normal way. now I'm trying to do
A normal UserControl looks like this in XAML: <UserControl x:Class=mynamespace.foo ...namespaces...> <!-- content -->
I have a set of strings and I need to find all all of
The Google Custom Search integration only includes numbered page links and I cannot find
i have a page, which has 2 links (search, normal button), both redirects are
A few micro-questions regarding normal!, incsearch and the / operator (search) . I'm not
My Normal search in the activescaffold list page is not working. I have ListLocations
I am trying to find the best way to create a dynamic meta robots

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.