NVIDIA Interview Question

first round an easy coding question, second round a puzzle question with some math involved