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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:21:52+00:00 2026-05-10T22:21:52+00:00

I hate to have to ask, but I’m pretty stuck here. I need to

  • 0

I hate to have to ask, but I’m pretty stuck here.

I need to test a sequence of numbers to find the first which has over 500 factors: http://projecteuler.net/index.php?section=problems&id=12

-At first I attempted to brute force the answer (finding a number with 480 after a LONG time)

-I am now looking at determining the prime factors of a number and then use them to find all other factors.

I am currently at the stage where I can get an array of prime factors for any number I input – i.e 300 has the prime factors 2 2 3 5 5

Using this array of prime factors I need to be able to calculate the remaining factors – This is the part I am stuck on. Basically, as I understand it, I need to calculate ALL possible combinations of the numbers in the array…

i.e 2 * 2
2 * 2 * 3
2 * 2 * 3 * 5
2 * 3
2 * 3 * 3
…and so forth – But where it gets interesting is with things like…
2 * 5
2 * 3 * 5
…i.e Numbers which are not adjacent to each other in the array

I can’t think of a way to code this in a generic fashion for any length array…

I need help! P.S – I am working in Java

EDIT: My brute force code – As it has been suggested brute forcing the problem will work and so there may be an error in my code 🙁

package euler.problem12;  public class Solution {      public static void main(String[] args) {         int next = 1;         int triangle = 0;         int maxFactors = 0;          while(true) {             triangle = triangle + next;              int factors = 1;             int max = (int) triangle / 2;              for(int i = 1; i <= max; ++i) {                 if(triangle % i == 0) {                     factors ++;                 }             }              if(factors > maxFactors) {                 maxFactors = factors;                  System.out.println(triangle + '\t' + factors);             }              next++;         }     } } 
  • 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. 2026-05-10T22:21:53+00:00Added an answer on May 10, 2026 at 10:21 pm

    As far as I can tell, question 12 doesn’t mention anything about prime numbers? Is this the one you’re looking at?

    The sequence of triangle numbers is generated by adding the natural numbers…

    If so, then perhaps not thinking about primes will help? 😉

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

Sidebar

Related Questions

I'd hate to ask an intentionally subjective question on here, but I don't have
I hate to ask this here, but many people on stackoverflow have talked about
I hate that I have to ask a homework question on here, but I
I hate to ask the same question others have asked in Stackoverflow, but I
I hate to ask but I had to. I have an html code. For
I hate to be the village idiot, but I have no clue how Linq
I love paredit. But there are a couple of things I hate, and have
I hate to post this but I am on a time crunch and need
I hate to ask this, but I'm in a time crunch and I'm hoping
well, I normally find the answer to my questions here but this time I

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.