Solución
solution.tsTypeScript
from functools import cached_property
class HeavyComputer:
def __init__(self, n):
self.n = n
@cached_property
def result(self):
# Calcula la suma de range(n) — se computa una sola vez y se cachea
sumatory = 0
for i in range(self.n):
sumatory += i
return sumatory
def compute_heavy(n):
h = HeavyComputer(n)
return h.result0respuestas