# math

Have you ever needed a way to style the elements of a set ( lets say 5 ) individually, but the same rules to be applied to other set ( of 5 ) ?

For example:

```<div>
<h4>first</h4>
<p>lorem ipsum ...</p>
<h4>second</h4>
<h4>third</h4>
<h4>forth</h4>
<div>lorem ipsum ...</div>
<h4>fifth</h4>
<!-- here end our first set -->
<h4>first</h4>
<h4>second</h4>
<h2>lorem ipsum ...</h2>
<h4>third</h4>
<span>lorem ipsum ...</span>
<h4>forth</h4>
<h4>fifth</h4>
<!-- here end our 2nd set -->
</div>
```

and we want that the first h4 in the first set have same styles as the first h4 in the second and so on, of course our h4’s are not grouped, but they are scattered between other elements, and other h4’s can be added in the future.

If we have a way to distinguish our elements from the other then we can make a short script with jQuery to add classes.

For a group of five css classes that will repeat after a number ( for this example we took, n = 5 ), this means that our h4’s from 1 to 5 will have same classes with the h4’s from 6 to 10, and so on; for this we will use something that in math is called ‘modulo’, basically gives us the remaining of the division of two numbers, and as we can get the index of our element we can see which position has in our set ( in this case of 5 ).

```\$('div h4').each(function(index) {

if(index%5 == 0){
} else if(index%5 == 1){
} else if(index%5 == 2){
} else if(index%5 == 3){
} else if(index%5 == 4){
}
});
```

the result would be:

```<div>
<h4 class="first">first</h4>
<p>lorem ipsum ...</p>
<h4 class="second">second</h4>
<h4 class="third">third</h4>
<h4 class="forth">forth</h4>
<div>lorem ipsum ...</div>
<h4 class="fifth">fifth</h4>
<!-- here end our first set -->
<h4 class="first">first</h4>
<h4 class="second">second</h4>
<h2>lorem ipsum ...</h2>
<h4 class="third">third</h4>
<span>lorem ipsum ...</span>
<h4 class="forth">forth</h4>
<h4 class="fifth">fifth</h4>
<!-- here end our 2nd set -->
</div>
```

## Math sophism on Pythagorean theorem

Good way to keep an idiot busy for a couple of hours.

cos2x + sin2x = 1 is the trigonometric form of the Pythagorean theorem

cos2x + sin2x = 1
cos2x = 1 – sin2x
cos x = (1 – sin2x)1/2
1 + cos x = 1 + (1 – sin2x)1/2
(1 + cos x)2 = (1 + (1 – sin2x)1/2)2
for x = π (pi = 3,14159265…), we have,
(1 – 1)2 = (1 + (1 – 0)1/2)2
0 = (1 + 1)2
0 = 4 //interesting ?!