JSFiddle - React, Tailwind, and code Playground
JavaScript
var fingers = 0;
var hands = 0;
var FINGER_NUMBER = 5;
/* MEAT */
function sum(a,b){
while(a-- > 0) {
finger_inc();
}
while(b-- > 0) {
finger_inc();
}
return count_hands_and_fingers(); // We count the number of hands and fingers
}
/* Private functions */
function finger_inc(){
if(++fingers >= FINGER_NUMBER) {
hands++;
fingers = 0;
}
}
function count_hands_and_fingers() {
var total_count = 0;
total_count = hands * FINGER_NUMBER;
total_count += fingers;
return total_count;
}
document.write(sum(1,50));