Published
Edited
Apr 21, 2020
1 fork
Insert cell
Insert cell
hasRepeatedDigits = n => n.toString()
.split('')
.some((digit, index, arr) => arr.indexOf(digit) !== index);
Insert cell
zeroToNine = [...Array(10).keys()];
Insert cell
divisibleByTwo = zeroToNine
.reduce((agg, cur) => agg.concat(zeroToNine.map(i => 10 * cur + i)), [])
.filter(n => n % 2 === 0 && !hasRepeatedDigits(n) && n >= 10);
Insert cell
divisibleByThree = divisibleByTwo
.reduce((agg, cur) => agg.concat(zeroToNine.map(i => 10 * cur + i)), [])
.filter(n => n % 3 === 0 && !hasRepeatedDigits(n));
Insert cell
divisibleByFour = divisibleByThree
.reduce((agg, cur) => agg.concat(zeroToNine.map(i => 10 * cur + i)), [])
.filter(n => n % 4 === 0 && !hasRepeatedDigits(n));
Insert cell
divisibleByFive = divisibleByFour
.reduce((agg, cur) => agg.concat(zeroToNine.map(i => 10 * cur + i)), [])
.filter(n => n % 5 === 0 && !hasRepeatedDigits(n));
Insert cell
divisibleBySix = divisibleByFive
.reduce((agg, cur) => agg.concat(zeroToNine.map(i => 10 * cur + i)), [])
.filter(n => n % 6 === 0 && !hasRepeatedDigits(n));
Insert cell
divisibleBySeven = divisibleBySix
.reduce((agg, cur) => agg.concat(zeroToNine.map(i => 10 * cur + i)), [])
.filter(n => n % 7 === 0 && !hasRepeatedDigits(n));
Insert cell
divisibleByEight = divisibleBySeven
.reduce((agg, cur) => agg.concat(zeroToNine.map(i => 10 * cur + i)), [])
.filter(n => n % 8 === 0 && !hasRepeatedDigits(n));
Insert cell
divisibleByNine = divisibleByEight
.reduce((agg, cur) => agg.concat(zeroToNine.map(i => 10 * cur + i)), [])
.filter(n => n % 9 === 0 && !hasRepeatedDigits(n));
Insert cell
divisibleByTen = divisibleByNine
.reduce((agg, cur) => agg.concat(zeroToNine.map(i => 10 * cur + i)), [])
.filter(n => n % 10 === 0 && !hasRepeatedDigits(n));
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