Algorithm 07: Sum Even Odd Patterns

This algorithm verifies that the sum of two or more number follows the following rules, and outputs an object with the results and errors:

  • even + even = even
  • even + odd = odd
  • odd + odd = even

 

A pattern I noticed when using more then two arguments is that if you have all odd numbers with an even number of arguments the results in an even sum.  For example:
isSumEvenOrOdd(7, 11, 13, 17, 47, 111) returns 206,

The same is true with an odd number of arguments, results in an odd sum.
isSumEvenOrOdd(7, 11, 13, 17, 47) returns 95.

Aren’t patterns interesting!

Like to leave a comment?

Comments have been automatically closed on this post but don't let that stop you. Hit me up on following networks: