News for hackers. Stuff that matters.
Re:Highlighting prime numbers with CSS by gus_massa on Monday August 07, 2017 @08:15AM (#14946917)
You can use the same trick dividing by all the numbers up to sqrt(n) [or n-1], instead of dividing by prime numbers.

You can replace

  li:first-child,
    li:nth-child(2n + 4),
    li:nth-child(3n + 6),
    li:nth-child(5n + 10),
    li:nth-child(7n + 14) {
      color: grey;
      counter-increment: nature-count nonprime-count;
    }
with

  li:first-child,
    li:nth-child(2n + 4),
    li:nth-child(3n + 6),
    li:nth-child(4n + 8),
    li:nth-child(5n + 10),
    li:nth-child(6n + 12),
    li:nth-child(7n + 14) 
    li:nth-child(8n + 16) 
    li:nth-child(9n + 18)
    li:nth-child(10n + 20) {
      color: grey;
      counter-increment: nature-count nonprime-count;
    }

There are no comments on this comment yet.