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 6696639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:21:55+00:00 2026-05-26T06:21:55+00:00

I am a beginning Octave user and would like to compute all the integer

  • 0

I am a beginning Octave user and would like to compute all the integer divisors of a number, for example, for the number 120, I would like to get 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, and 120.

I know octave has the factor function, but this only gives the prime factorization. I’d like all the integer divisors.

  • 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-26T06:21:55+00:00Added an answer on May 26, 2026 at 6:21 am

    I don’t think there’s a built-in function for this, so you will need to write one. Since each factor is the product of a subset of the prime factors, you can use a few built-in functions to build up the desired result.

    function rslt = allfactors(N)
    %# Return all the integer divisors of the input N
    %# If N = 0, return 0
    %# If N < 0, return the integer devisors of -N
        if N == 0
            rslt = N;
            return
        end
        if N < 0
            N = -N;
        end
    
        x = factor(N)'; %# get all the prime factors, turn them into a column vector  '
        rslt = []; %# create an empty vector to hold the result
        for k = 2:(length(x)-1)
            rslt = [rslt ; unique(prod(nchoosek(x,k),2))];
            %# nchoosek(x,k) returns each combination of k prime factors
            %# prod(..., 2) calculates the product of each row
            %# unique(...) pulls out the unique members
            %# rslt = [rslt ...] is a convenient shorthand for appending elements to a vector
        end
        rslt = sort([1 ; unique(x) ; rslt ; N]) %# add in the trivial and prime factors, sort the list
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just beginning with python and know enough to know I know nothing. I would
I am beginning a new Java web application using Netbeans, and I would like
Many beginning programmers write code like this: sub copy_file ($$) { my $from =
At the beginning of all my executable Python scripts I put the shebang line:
I am just beginning Haskell, but from all the online tutorials I've found I
When beginning to develop against SharePoint I did not fully understand all the ins
I'm beginning under NodeJS/Express and I'm facing the following problem (I probably didn't get
Beginning with a letter I know how to do: WHERE mov_title REGEXP CONCAT('^(the )?',
I am beginning with Android and I'd like to add tabs to my existing
At the beginning of my controller I have filter_resource_access which requires login for all

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.