Add powerrelative and fix calculation, drop some wiki data along constant

This commit is contained in:
Mylloon 2022-06-23 13:29:52 +02:00
parent dbe054e51b
commit 60e7df2e9d
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -13,9 +13,9 @@ const main = () => {
// Callback: called when firstname is changed // Callback: called when firstname is changed
const update_const = () => { const update_const = () => {
const firstname = document.getElementById(input_name).value; const firstname = document.getElementById(input_name).value;
const firstname_const = get_const(firstname.toLowerCase().split('')); const data = get_const(firstname.toLowerCase().split(""));
console.log(`output: ${firstname_const}`); console.log(`output: ${data.const} - ${JSON.stringify(data.infos)}`);
}; };
const get_const = (letters = Array) => { const get_const = (letters = Array) => {
@ -25,67 +25,181 @@ const get_const = (letters = Array) => {
let const_data = []; let const_data = [];
// Store some constants info // Store some constants info
//let const_infos = {}; let const_infos = {};
// Assign each letter to a const, fallback to 1 if no one has been found // Assign each letter to a constant, fallback to 1 if no one has been found
switch (letters) { let position = 0;
case 'a': // https://en.wikipedia.org/wiki/Artin%27s_conjecture_on_primitive_roots letters.forEach(letter => {
const_data.push(0.373955); position++;
case 'b': // https://en.wikipedia.org/wiki/Backhouse%27s_constant switch (letter) {
const_data.push(1.456074); case "a":
case 'c': // https://en.wikipedia.org/wiki/Porter%27s_constant const_data.push(0.373955 ** position);
const_data.push(1.46707807943397547289); const_infos[letter] = {
/* case 'd': "wikipedia": "https://en.wikipedia.org/wiki/Artin%27s_conjecture_on_primitive_roots"
const_data.push(); */ }
case 'e': // https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93Borwein_constant break;
const_data.push(1.606695); case "b":
case 'f': // https://en.wikipedia.org/wiki/Frans%C3%A9n%E2%80%93Robinson_constant const_data.push(1.456074 ** position);
const_data.push(2.807770); const_infos[letter] = {
case 'g': // https://en.wikipedia.org/wiki/Gauss%27s_constant "wikipedia": "https://en.wikipedia.org/wiki/Backhouse%27s_constant"
const_data.push(0.834626); }
/* case 'h': break;
const_data.push(); */ case "c":
/* case 'i': const_data.push(1.46707807943397547289 ** position);
const_data.push(); */ const_infos[letter] = {
/* case 'j': "wikipedia": "https://en.wikipedia.org/wiki/Porter%27s_constant"
const_data.push(); */ }
case 'k': // https://en.wikipedia.org/wiki/Landau%E2%80%93Ramanujan_constant break;
const_data.push(0.764223); /* case "d":
case 'l': // https://en.wikipedia.org/wiki/Lochs%27s_theorem const_data.push(x ** position);
const_data.push(0.97027011439203392574); const_infos[letter] = {
case 'm': // https://en.wikipedia.org/wiki/Meissel%E2%80%93Mertens_constant "wikipedia": ""
const_data.push(0.261497); }
/* case 'n': break; */
const_data.push(); */ case "e":
/* case 'o': const_data.push(1.606695 ** position);
const_data.push(); */ const_infos[letter] = {
case 'p': // https://en.wikipedia.org/wiki/Universal_parabolic_constant "wikipedia": "https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93Borwein_constant"
const_data.push(2.29558714939263807403); }
/* case 'q': break;
const_data.push(); */ case "f":
/* case 'r': const_data.push(2.807770 ** position);
const_data.push(); */ const_infos[letter] = {
case 's': // https://en.wikipedia.org/wiki/MRB_constant "wikipedia": "https://en.wikipedia.org/wiki/Frans%C3%A9n%E2%80%93Robinson_constant"
const_data.push(0.18785964246206712024); }
/* case 't': break;
const_data.push(); */ case "g":
/* case 'u': const_data.push(0.834626 ** position);
const_data.push(); */ const_infos[letter] = {
/* case 'v': "wikipedia": "https://en.wikipedia.org/wiki/Gauss%27s_constant"
const_data.push(); */ }
/* case 'w': break;
const_data.push(); */ /* case "h":
/* case 'x': const_data.push(x ** position);
const_data.push(); */ const_infos[letter] = {
/* case 'y': "wikipedia": ""
const_data.push(); */ }
/* case 'z': const_infos[letter] = {
const_data.push(); */ "wikipedia": ""
}
break; */
/* case "i":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
/* case "j":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
case "k":
const_data.push(0.764223 ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Landau%E2%80%93Ramanujan_constant"
}
break;
case "l":
const_data.push(0.97027011439203392574 ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Lochs%27s_theorem"
}
break;
case "m":
const_data.push(0.261497 ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Meissel%E2%80%93Mertens_constant"
}
break;
/* case "n":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
/* case "o":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
case "p":
const_data.push(2.29558714939263807403 ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/Universal_parabolic_constant"
}
break;
/* case "q":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
/* case "r":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
case "s":
const_data.push(0.18785964246206712024 ** position);
const_infos[letter] = {
"wikipedia": "https://en.wikipedia.org/wiki/MRB_constant"
}
break;
/* case "t":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
/* case "u":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
/* case "v":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
/* case "w":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
/* case "x":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
/* case "":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
/* case "z":
const_data.push(x ** position);
const_infos[letter] = {
"wikipedia": ""
}
break; */
default: default: // By default, equals to 1
const_data.push(1); const_data.push(1);
} }
});
// Multiply all the constants together // Multiply all the constants together
return const_data.reduce((a, b) => a * b); return {
"const": const_data.reduce((x, y) => x * y),
"infos": const_infos
};
}; };