// A lock has a three pin combination to unlock it. A program to list all possible combinations
(function() {
var i = 0,
j = 0,
k = 0;
var max = 9;
for (i; i <= max; i++) {
for (j = i; j <= max; j++) {
for (k = j; k <= max; k++) {
console.log(i + "" + j + "" + k);
}
}
}
})();
// A program to display multiplication table
(function() {
var i = 0,
j = 0,
k = 0,
max = 25,
result = 0,
sym = "";
for (i = 1; i <= max; i++) {
for (j = 1; j <= max; j++) {
result = i + "*" + j + "=" + i * j;
sym = result.length;
console.log(result);
}
console.log(Array(sym + 1).join("*")); //
}
})();
/*
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
[Euler project - problem 1](https://projecteuler.net/problem=1)
*/
(function() {
var i = 0,
max = 1000,
sum = 0;
for (i = 1; i < max; i++) {
if (i % 3 == 0 || i % 5 == 0) {
sum = sum + i;
}
}
console.log(sum);
})();
Last active
October 17, 2017 11:14
-
-
Save kranthilakum/f7a3fbcbfe7bff3159bfa0b3f32aa845 to your computer and use it in GitHub Desktop.
Scripts - Code Kata
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment