let sqrt = fun(number) {

    let sqrt_iter = fun(past, current, number) {
        if(is_good_enough(past, current)) {
            return current;
        }
        let better = improve(current, number);
        return sqrt_iter(current, better, number);
    }
  
    let is_good_enough = fun(past, current) {
        return abs(past - current) < 100;
    }

    let improve = fun(guess, number) {
        return average(guess, (x / guess));
    }

    let average = fun(ceiling, floor) {
        return (ceiling + floor) / 2;
    }

    let abs = fun(number) {
        if(number < 0) {
            return -number;
        }
        return number;
    }

    let square = fun(number) {
        return number * number;
    }

    return sqrt_iter(0, 1, number);
}

sqrt(10000);