Solución

@kappa_cat
·hace 9hTypeScript
solution.tsTypeScript
export function sumFirstOdds(n: number): number {
  // Create an array with N length and fill it with odd numbers (2 * index + 1), then do total sum
  return Array.from({ length: n }, (_, i) => 2 * i + 1).reduce((total, current) => total + current, 0)
}
0respuestas
Respuestas
0

Aún no hay respuestas

¡Sé el primero en responder!

Escribir un comentario

Recuerda ser amable. Estás comentando la solución de otra persona. Comparte tu perspectiva de forma constructiva y respetuosa.

Debes iniciar sesión para publicar un comentario.
Markdown