function length_of_factorial(N) {
if (N < 2) return 1;
sum = 0;
for (i = 2; i <= N; i++) {
sum += Math.log(i) / Math.log(10)
}
return Math.floor(sum) + 1
}
View Journey-to-the-Moon.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function processData(input) { | |
var temp = input.split('\n') | |
var [ N, I ] = temp.shift().split(' ').map( Number ) | |
// generate graph | |
var graph = [] // store in an array of Set [ 0 : [ 0, 1 ], 1 : [ 3, 2 ] ] (to prevent duplicate) | |
var relationalMap = {} // use to remember the map { 0 : 0, 1 : 0, 2 : 1, 3 : 1 } | |
for(let i = 0; i < I;i++) | |
{ |
View digits_factorial.md
View three_points.md
N = _fArgs[0]
P1 = N[0]
P2 = N[1]
P3 = N[2]
// area - check http://www.gottfriedville.net/mathtools/triarea.html
Area = Math.abs((P1[0]*(P2[1]-P3[1]) + P2[0]*(P3[1]-P1[1]) + P3[0]*(P1[1]-P2[1]))/2)
View spiral-order.md
It's from others.
function spiralMatrix(matrix) {
var i;
var top = 0;
var left = 0;
var bottom = matrix.length;
var right = matrix[0].length;
View taller.md
Original answer
function Taller (N,M) {
var output = [];
// check every element
for (i=0;i<N;i++) {
var temp = [];
View trailing_zero.md
function superfactorialZeros(N) {
var result = 0;
for (i = 1; i <= N; i++) {
result += zeroes(i);
}
return result;
}
View gogo.md
function PrimeOperations(X, Y) {
var x = getPrimeFactors(X),
y = getPrimeFactors(Y),
k = 0;
for(i=0;x[i];i++) {
for (j=0;y[j];j++) {
if (x[i] == y[j]) {
k += 2;
View test.md
o = ''
b = arguments[0]
for (k in b)
o += ' d3d4d5 d7 e6e5e4 f2 h2h1g1 e1d1c1b1 a2 c2'.substr(b[k].charCodeAt() *2,2)
return o
View ^6-^2.md
65 char
n = arguments[0]
s = n*n*++n*n/4
while(k=--n*n*n)
s -= k*k
View encrypt.md
function arr_encryption(msg) {
var message = msg.split(' ').join('.'),
output = '';
// add . if needed
for (k=0;k<message.length % 6;k++) {
message += '.';
}
NewerOlder