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

  • Home
  • SEARCH
  • 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 6147579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:07:37+00:00 2026-05-23T19:07:37+00:00

I want a combination algorithm,…to multiple the elements in the array, to every other

  • 0

I want a combination algorithm,…to multiple the elements in the array, to every other element but itself….

please help me to combine eg:: {1,2,3,4,5,6}

output:: 1*2,1*3….1*6, 1*2*3 !*2*4…….1*2*3*4*5*6…….5*6

code removed it was irrelevant to my logical requirement of question…

  • 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-23T19:07:38+00:00Added an answer on May 23, 2026 at 7:07 pm

    I believe this is what you are looking for:

    //This method return a list of lists, where each "inner list" contains as
    //its first number the number for which the factors are being found, and
    //every other number is a factor.
    //It takes an array of all the numbers whose factor you wish to find
    public List<List<Integer>> getAllFactors(int[] toCalculate){
        List<List<Integer>> toReturn = new ArrayList<List<Integer>>();
        List<Integer> factors;
        for(int i = 0; i < toCalculate.length; i++){
            factors = new ArrayList<Integer>();
            factors.add(toCalculate[i]); //add the number whose factors will be calculated
            //the square root is used because it is the largest number you can divide by without getting "overlap"
            for(int j = 1; j <= Math.sqrt(toCalculate[i]); j++){ 
                if(toCalculate[i]%j==0){ //if it divides evenly, add it
                    factors.add(j);
                    factors.add((Integer)toCalculate[i]/j); //also add its "partner" number
                }
            }
            toReturn.add(factors);
        }
        return toReturn;
    }
    

    I put in class Test… Here is my testing method:

    public static void main(String[] args){
        Test t = new Test();
        List<List<Integer>> blah = t.getAllFactors(new int[]{10, 12, 1, 5});
        for(List<Integer> i: blah)
            System.out.println(Arrays.toString(i.toArray(new Integer[i.size()])));
    }
    

    I realized that this wasn’t what the question asked for… I think… I can’t really tell…
    Anyway, I wrote an alternative method:

    public List<Integer> getAllFactors(int number){
        List<Integer> factors = new ArrayList<Integer>();
        for(int i = 2; i <= Math.sqrt(number); i++){
            if(number%i==0){
                factors.add(number);
                factors.addAll(getAllFactors(i));
                factors.addAll(getAllFactors(number/i));
            }
        }
        if(factors.isEmpty())
            factors.add(number);
        return factors;
    }
    

    But then I realized that might not be what you want either. The fact is, I actually have no fricking clue what you are looking for, I can’t understand your post. I have just been trying to glean info from the comments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a program that would print every combination of a set
I want to find records on a combination of created_on >= some date AND
I want to set up a content mgmt system. And i feel the combination
I have an array of 7 numbers (1,2,3,4,5,6,7) and I want to choose 5
i want to create an algorithm or formula that gives me the following combinations
I want an algorithm which would create all possible phrases in a block of
I want to find the all possible combination of a given word. For example
I want a cron job (or a combination of 2 jobs) which fires at
I want to iterate through all 5 character combinations of 0-9, a-z. I worked
I have a private const int defined in a C# class. I want compilation

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.