0

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.

  • 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? – dxiv Apr 06 '18 at 05:59
  • 1
    I guess what you're looking for is Highly Composite Numbers (search in Google) – Matti P. Apr 06 '18 at 06:05
  • @dxiv I edited my answer. – Jens Törnell Apr 06 '18 at 06:07
  • @MattiP. Yes it looks like it. Thanks! – Jens Törnell Apr 06 '18 at 06:08
  • In practise, I would suggest you to 1) consider what are the row lengths that you're working with; and 2) take the least common multiple of the numbers that you chose; and 3) The result (and its multiples) is the number of items that you want to show. – Matti P. Apr 06 '18 at 06:10
  • 1
    @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,$. – dxiv Apr 06 '18 at 06:11
  • 1
    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. – Matti P. Apr 06 '18 at 06:11
  • 1
    https://www.wolframalpha.com/input/?i=lcm(1,2,3,4,5,6,7,8) – Matti P. Apr 06 '18 at 06:15
  • @MattiP. Yes, I just figured out the same thing. 60 is the perfect number for my gallery. It may be a bit high but it can make full rows with 1,2,3,4,5,6 which is really cool. – Jens Törnell Apr 06 '18 at 06:15
  • @MattiP. An image gallery with 840 items, that would be something. ;) It's also a perfect number which is too high in my case. Nice lcm formula. – Jens Törnell Apr 06 '18 at 06:17
  • for 1 or 2 columns: 2 items

    for 1 to 3 columns: 6 items

    for 1 to 4 columns: 12 items

    for 1 to 5 columns: 60 items

    for 1 to 6 columns: Also 60 items - making it work for 2 and 3 gives you 6 for free.

    for 1 to 7 columns: 420 items. 7 is a troublemaker.

    for 1 to 8 columns: 840 items. For 1 to 8, exculding 7, 120 items.

    for 1 to 9 columns: 2520 items. And making it work for 2 and 5 gives you 10 for free.

    Leaving the troublemaking 5 and 7 out: 72 fits neatly into 1,2,3,4,6,8,9,12,etc cols. Or, bringing 5 back, 360 items fits neatly into 1,2,3,4,5,6,8,9,10,etc columns.

    – Michael Hartley Apr 06 '18 at 06:19
  • Also, please pay attention to your word choice in the future. These numbers are not Perfect Numbers in the traditional sense of the word (google again). – Matti P. Apr 06 '18 at 06:23
  • @MattiP. So what do you think I should write instead? "composite number"? 48 is a composite number, but it's not dividable with 5 while 60 is. – Jens Törnell Apr 06 '18 at 06:30

0 Answers0