Instantly share code, notes, and snippets.

# Incognito/Inclusion-exclusion.tex Created Dec 20, 2011

What would you like to do?
Euler 001
 /*Generate a list of all Combinations*/ function getCombinations(list){ var combinations = []; //All combinations var combination = []; //Single combination var quantity = (1 << list.length); for (var i = 0; i < quantity ; i++){ combination = []; for (var j=0;j
 function sumMultiplesOfTwoOrThree(n){ var sum= 0; var arithmeticSum = function(a, n){ return (1/2)*n*(a+a*n); }; var arithmeticSumFromSeriesMultiple = function(series, multiple){ series -=1; //Euler problem #1 wants numbers less than 1000. var a = multiple; var n = Math.floor(series/multiple); return arithmeticSum(a, n); } sum += arithmeticSumFromSeriesMultiple(1000, 3); sum += arithmeticSumFromSeriesMultiple(1000, 5) sum -= arithmeticSumFromSeriesMultiple(1000, 15); return sum; } console.log(sumMultiplesOfTwoAndThree(1000))
 function sumMultiples(n, multiples){ var sum= 0; var isMultiple = function(n, multiple){ return ((n % multiple) === 0); }; var commonMultiples = function (n,multiples){ var isCommon = false; for (var i=0;i
 function sumMultiplesOfTwoAndThree(n){ var sum= 0; for (var i=1;i
 function getCombinations(list){ var combinations = []; //All combinations var combination = []; //Single combination var quantity = (1 << list.length); for (var i = 0; i < quantity ; i++){ combination = []; for (var j=0;j
 $| \bigcup\limits_{i=1}^n A_i | =$ $+ ( \sum\limits_{i=0}^n | A_i | )$ \$ - ( \sum\limits_{i,j:1 \le i