[Community Puzzle] Sum of odd

Hello, I would like advice on this codingame puzzle.

(sum of odd), I find the solutions well, but in too long a time. I wouldn’t like to have the solution, but knowing where to look if it’s more Mathematical (formula) or Algorithmic is how to optimize this one.

codingame exo: Coding Games and Programming Challenges to Code Better

my code: Sum of odd · GitHub

Sincerely, Maxime

A general formula for sum of consecutive odd integers, and an algebra identity may help here.