Skip to content

Commit

Permalink
Added Gematria function
Browse files Browse the repository at this point in the history
  • Loading branch information
jesuscaesar committed Sep 6, 2024
1 parent 9b7b8d6 commit d12ad8c
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,20 @@ function hex2bin(hex, offs = 0) {
} return res;
}
function sumstr(str) {
var res = 0;
if (str != '') {
var sum = 0, x = 0;
for (i = 0; i < str.length; i++) {
x = str.codePointAt(i);
sum += str.codePointAt(i);
} res = sum;
} else {
res = 0;
} return res;
var sum = 0;
for (i = 0; i < str.length; i++) {
sum += str.codePointAt(i);
} return sum;
}
function gemstr(str) {
var res = 0;
if (str != '') {
var sum = 0, x = 0;
for (i = 0; i < str.length; i++) {
x = str.codePointAt(i);
sum += 10*Math.floor((x-1)/9)*((x-1%9)+1);
} res = sum;
} else {
res = 0;
} return res;
var sum = sumstr(str);
var word = sum.toString();
var out = 0, tex = word.split('');
while (tex.length > 1) {
out = 0; for (ch in tex) {
out += parseInt(tex[ch]);
} tex = out.toString().split('');
} return parseInt(tex);
}
function arraySearch(needle, haystack) {
for (key in haystack) {
Expand Down

0 comments on commit d12ad8c

Please sign in to comment.