Published
Edited
Jan 31, 2018
Insert cell
Insert cell
Insert cell
numberOddFactors = d3.range(0, 121).map(n => {
if (n < 2) return []
return getOddFactors(factor(n))
})
Insert cell
Insert cell
factorialOddFactors = numberOddFactors.map((d, i) => {
return getOddFactors(_.flatten(numberOddFactors.slice(0, i + 1)))
})
Insert cell
Insert cell
getOddFactors(_.flatten(factorialOddFactors))
Insert cell
function factor(n){
var factors = []
for (var i = 2; i <= n; i++){
while (n % i == 0){
n = n / i
factors.push(i)
}
}
return factors
}
Insert cell
function getOddFactors(factors){
return d3.nestBy(factors, d => d)
.filter(d => d.length % 2)
.map(d => d[0])

}
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more