def tetrate(a, tetrate_acc):
assert is_valid_other(a), "not a valid other"
assert is_valid_accumulator(tetrate_acc), "not a valid accumulator"
assert a > 0, "we don't define 0↑↑b"
exponentiate_acc = xmpz(1)
for _ in count_down(tetrate_acc):
multiply_acc = xmpz(1)
for _ in count_down(exponentiate_acc):
add_acc = xmpz(0)
for _ in count_down(multiply_acc):
for _ in range(a):
add_acc += 1
multiply_acc = add_acc
exponentiate_acc = multiply_acc
return exponentiate_acc
And here is the final function in Rust:
(I used `&mut` instead of returned values because I don't think Rust guarantees that returned owned values aren't copied.)
fn tetrate(a: u32, acc: &mut BigUint) {
assert!(a > 0, "we don’t define 0↑↑b");
let mut exp = BigUint::from(1u32);
for () in acc.count_down() {
let mut mul = BigUint::from(1u32);
for () in exp.count_down() {
let mut add = BigUint::ZERO;
for () in mul.count_down() {
for _ in 0..a {
add += 1u32;
}
}
mul = add;
}
exp = mul;
}
*acc = exp;
}
You can hook it up to a cloud service, say an S3 bucket, and allocate storage space as needed. Then it fulfills the condition of unbounded memory, at the small price of unbounded cost. But it will not be a problem during your lifetime.
If you are cloud-averse, you could do the same with networked storage on your local LAN and just connect more disks when it's running out.
In school we learn to "solve" y = x² and get x = ±√y. But they never teach that (or why) you can't solve y = x −c sin(x) and get a nice equation. That's always bugged me. Instead of learning Galois theory, I cheated and used Python's free SymPy package to search for unsolvable equations.
reply