We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #12: Highly divisible triangular number
  4. Discussions

Project Euler #12: Highly divisible triangular number

Problem
Submissions
Leaderboard
Discussions

Sort 97 Discussions, By:

votes

Please Login in order to post a comment

  • mtarekcse1 4 years ago+ 0 comments

    hint : if the prime factors of a number is a^n , b^m , c^q then the number of divisors is (n+1)(m+1)(q+1)

    52|
    Permalink
  • empty_life 5 years ago+ 0 comments

    well , all hint i can give u is for n =1000 , we have 842161320 as our triangular number which is ( (41040)*(41040 +1))/2

    15|
    Permalink
  • Umasou 5 years ago+ 0 comments

    I was confused by the contest requirement. When N = 7, the right answer is 36, which has #9 factors, however 66 has #8 factors, because 66 has less factors than 36, I ordered triangle numbers by their factor numbers and kept getting the wrong answer.

    I am writing this in case someone has the same misunderstanding.

    13|
    Permalink
  • anuraggupta14_11 3 years ago+ 0 comments

    MY JAVA CODE PASSES 100% TEST CASES..ENJOY

    import java.io.*;
    import java.util.*;
    import java.math.*;
    public class Solution {
        static int factor(int a){
            int count=0;
            if(a==1){
                return 1;
            }
            for(int i=1;i<Math.ceil(Math.sqrt(a));i++){
                if(a%i==0){
                    count+=2;
                }
            }
            if((Math.ceil(Math.sqrt(a)))==Math.floor(Math.sqrt(a))){
                count++;
            }
            return count;
        }
        public static void main(String[] args) {
            int arr[] = new int[1001];
            int temp=0,box=0;
            for(int i=1;i<=1000;i++){
                while(temp<=i){
                    box++;
                    temp=factor(((box)*(box+1))/2);
                    
                }
                arr[i]=((box)*(box+1))/2;
            }
            Scanner sc = new Scanner(System.in);
            int test = sc.nextInt();
            while(test-->0){
                int n=sc.nextInt();
                System.out.println(arr[n]);
            }
        }
    }
    
    6|
    Permalink
  • hengliustudy 6 years ago+ 0 comments

    I always get time out on #6 and #7, any hints?

    6|
    Permalink
Load more conversations

Need Help?


View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature