ciphAx's blog

By ciphAx, history, 6 years ago, In English
Hello,
It would be great if I can get some nudge in the right direction for the following question :

There is a sequence that contains in ascending order natural numbers that are products of at least two natural consecutive number, example : 

2,6,12,20,24,30,42,56,60,72,..
Find the nth natural number in the sequence

n = 1 , result = 2 ( 1 * 2)

n = 2 , result = 6 ( 2 * 3)

n = 4, result = 20 ( 4 * 5)

n = 9, result = 60 ( 3 * 4* 5)

1 <= n <= 10^6

result must be smaller than or equal to 10^12.
  • Vote: I like it
  • -5
  • Vote: I do not like it

| Write comment?
»
6 years ago, hide # |
← Rev. 2  
Vote: I like it +10 Vote: I do not like it

Since we know that the $$$ \text{result} \leq 10^{12} $$$, for a product of $$$2$$$ consecutive numbers the max value of the larger of the $$$2$$$ numbers = $$$10^6$$$. Also, we know the length of the longest product of consecutive numbers = $$$14$$$ because $$$ 15! \gt 10^{12} $$$. Could we possibly brute force this?

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    It is not necessary to get a product of only 2 consecutive numbers. It can be more as well. It says at least 2 consecutive numbers. In this case, I wasn't able to come up with a brute force which gave the ascending order as well

    • »
      »
      »
      6 years ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Yeah, and like I've said above the longest possible product of consecutive numbers = $$$14$$$. Since we know that there are $$$10^6$$$ ways to have a product of $$$2$$$ consecutive numbers and clearly less ways to have a product of $$$3, \dots ,14$$$ consecutive numbers, we can bound the total number of values to check by $$$10^6 \cdot (14-1) \approx 10^7$$$. We can just go through all values in a double for loop and add them to a set. The nth number in this set is the result.

»
6 years ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it
are this examples correct
n = 1 , result = 2 ( 1 * 2)
n = 2 , result = 6 ( 2 * 3)
n = 3 , result = 6 (1 * 2 * 3)

n = 4 , result = 12 ( 3 * 4 )
but here it is 20, am I missing something
n = 4, result = 20 ( 4 * 5) ??
  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    The sequence is 2,6,12,20,24,30,42,56,60,72 n=3 is 12. So I think multiple ways to reach a nth term all count as one term