[2, 3, 5, 7, 11, 13]
randFromArray([
4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26,
27, 28, 30, 32, 33, 35, 36, 39, 40, 42, 44, 45, 48, 49, 50,
52, 54, 55, 56, 60, 63, 65, 66, 70, 72, 75, 77, 78, 80, 81,
84, 88, 90, 91, 96, 98, 99])
getPrimeFactorization(NUMBER)
_.reduce(FACTORIZATION, function(exponents, base) {
exponents[base] = exponents[base] + 1 || 1;
return exponents;
}, {})
_.reduce(_.values(EXPONENTS), function(hasExponents, num) {
return hasExponents || num !== 1;
}, false)
_.map(EXPONENTS, function(num, prime) {
return cardinalThrough20(num) + " <code>" + prime + "</code>" + (num === 1 ? "" : "s");
})
_.reduce(PRIMES, function(factors, prime) {
if (EXPONENTS[prime] > 1) {
factors.push(prime + "^" + EXPONENTS[prime]);
} else if (EXPONENTS[prime] === 1) {
factors.push(prime);
}
return factors;
}, []).join("\\cdot")
_.map(FACTORIZATION, function(factor, step){
var remain = NUMBER;
_.each(FACTORIZATION.slice(0, step), function(n) { remain /= n; })
return remain;
})
null
Find the prime factorization of NUMBER
.
Use the arrows to change the exponent on each prime number below to see if you can find the
prime factorization.
// Save a reference to KhanUtil.currentGraph.graph to workaround the issue
// of the custom validator depending on KhanUtil.currentGraph and
// KhanUtil.currentGraph changing because of the second graphie element
// in the hints.
GRAPHIE = graph;
init({
range: [[0, 10], [-11, 0]]
});
addMouseLayer();
graph.primes = [];
graph.computeTotal = function() {
return _.reduce(PRIMES, function(total, prime) {
return total * pow(prime, graph.primes[prime].exponent);
}, 1);
};
graph.totalLabel = label([7, -10], 1, "right", {fontSize: 25});
graph.updateTotal = function() {
this.totalLabel.remove();
this.totalLabel = label([7, -10], graph.computeTotal(), "right", {fontSize: 25});
var answerPreview = _.reduce(PRIMES, function(answer, prime) {
if (graph.primes[prime].exponent > 1) {
answer.push(prime + "^" + graph.primes[prime].exponent);
} else if (graph.primes[prime].exponent === 1) {
answer.push(prime);
}
return answer;
}, []).join("\\cdot");
if (answerPreview) {
answerPreview += " = ";
}
answerPreview += graph.computeTotal();
KhanUtil.processMath($("#answer-preview code")[0], answerPreview, true);
};
_.each(PRIMES, function(prime, y) {
var yCoord = -y * 1.5 - 1;
graph.primes[prime] = {
exponent: 0,
baseLabel: label([2, yCoord], prime, "left", {fontSize: 25, color: "#aaa"}),
expLabel: label([2, yCoord + 0.3], 0, "center", {fontSize: 20, color: "#aaa"}),
expandLabel: label([3, yCoord], 1, "right", {fontSize: 20, color: "#aaa"}),
factorLabel: label([7, yCoord], 1, "right", {fontSize: 25, color: "#aaa"}),
upArrow: addArrowWidget({
coord: [2, yCoord + 0.7],
direction: "up"
}),
downArrow: addArrowWidget({
coord: [2, yCoord - 0.1],
direction: "down"
}),
update: function() {
this.expLabel.remove();
this.expandLabel.remove();
this.factorLabel.remove();
this.expLabel = label([2, yCoord + 0.3], this.exponent, "center", {fontSize: 20});
this.factorLabel = label([7, yCoord], pow(prime, this.exponent),
"right", {fontSize: 25});
if (this.exponent === 0) {
this.baseLabel.css({color: "#aaa"});
this.expLabel.css({color: "#aaa"});
this.expandLabel = label([3, yCoord], "1", "right", {fontSize: 20, color: "#aaa"});
this.factorLabel.css({color: "#aaa"});
} else {
this.baseLabel.css({color: "black"});
this.expandLabel = label([3, yCoord],
getPrimeFactorization(pow(prime, this.exponent)).join("\\cdot"),
"right", {fontSize: 20});
}
if (this.exponent >= 5 || (prime >= 11 && this.exponent >= 3)) {
this.upArrow.hide();
} else {
this.upArrow.show();
}
if (this.exponent <= 0) {
this.downArrow.hide();
} else {
this.downArrow.show();
}
}
};
graph.primes[prime].upArrow.onClick = function() {
graph.primes[prime].exponent += 1;
graph.primes[prime].update();
graph.updateTotal();
};
graph.primes[prime].downArrow.onClick = function() {
graph.primes[prime].exponent -= 1;
graph.primes[prime].update();
graph.updateTotal();
};
label([2.5, yCoord], "=", "right", {color: "#ccc"});
label([6.5, yCoord], "=", "right", {color: "#ccc"});
graph.primes[prime].downArrow.hide();
});
line([0, -9.25], [8, -9.25]);
label([0, -9], "\\times", "above right", {fontSize: 25});
GRAPHIE.computeTotal()
if (guess === 1) {
return "";
}
return guess === NUMBER;
_.each(PRIMES, function(prime) {
GRAPHIE.primes[prime].exponent = 0;
});
_.each(getPrimeFactorization(guess), function(prime) {
GRAPHIE.primes[prime].exponent += 1;
});
_.each(PRIMES, function(prime) {
GRAPHIE.primes[prime].update();
});
GRAPHIE.updateTotal();
_.each(PRIMES, function(prime) {
GRAPHIE.primes[prime].exponent = 0;
});
_.each(getPrimeFactorization(guess), function(prime) {
GRAPHIE.primes[prime].exponent += 1;
});
GRAPHIE.updateTotal();