from typing import List


def totient_upto(n: int) -> List[int]: 
    """Return all Euler's totient function values upto n in O(Nlog(logN))."""
    ans = list(range(n+1))
    for x in range(2, n+1): 
        if ans[x] == x: 
            for xx in range(x, n+1, x): 
                ans[xx] -= ans[xx]//x 
    return ans