0
$\begingroup$

I'm really no math expert but a decent web developer with a simple problem.

I have a gallery with items. I can decide how many items I show on each page. I'll give an example...

Example with 9 in a row

Match row length

Each line is filled up with 3 in a row. Nice!

|x|x|x|
|x|x|x|
|x|x|x|

Does not match row length

When having 4 in a row, it "breaks".

|x|x|x|x|
|x|x|x|x|
|x|

Conclusion: 9 is only a good items number for 1, 3 and 9 in a row. But not for 2, 4 and 5.

Question

  • The number 9 is not a very good number, because it's often get uneven to the row length.
  • The number 12 is much better as it match 1, 2, 3 and 4. It starts perfectly with the first four numbers dividable. I could only wish it would be dividable with 5 etc as well. The number 12 is better than 9 in this case.

Are there more perfect numbers? I don't need more than 8 in a row.

For other readers here, I guess a math formula would be really helpful as well.

$\endgroup$
13
  • $\begingroup$ it's a perfect number as it's possible to divide with the first four numbers But not with $\,5, 7, 8, 9, 10, 11\,$, so what makes it "perfect" for your use-case?. You'll need to explain that better. Maybe you mean the least common multiple of the first $\,n\,$ positive integers? $\endgroup$
    – dxiv
    Apr 6, 2018 at 5:59
  • 1
    $\begingroup$ I guess what you're looking for is Highly Composite Numbers (search in Google) $\endgroup$
    – Matti P.
    Apr 6, 2018 at 6:05
  • 1
    $\begingroup$ @JensTörnell That sounds like $\,\operatorname{lcm}(1,2,\ldots,n)\,$ indeed, which does not have a "nice" closed form. But given your $\,n \le 8\,$, it's only $\,8\,$ values to calculate. Note however that $\,\operatorname{lcm}(1,2,3,4,5,6,7,8)\,$ is $\,840\,$. $\endgroup$
    – dxiv
    Apr 6, 2018 at 6:11
  • 1
    $\begingroup$ For example, if you choose that the row lengths that you want to work with are 2,3, 4 and 5, their LCM is 60. $\endgroup$
    – Matti P.
    Apr 6, 2018 at 6:11
  • 1
    $\begingroup$ wolframalpha.com/input/?i=lcm(1,2,3,4,5,6,7,8) $\endgroup$
    – Matti P.
    Apr 6, 2018 at 6:15

0

You must log in to answer this question.

Browse other questions tagged .