From 01c6457aab3de26ee00a8573f84ddb7d1fb623f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Fernandes?= Date: Mon, 11 Nov 2024 07:08:08 -0300 Subject: [PATCH] [gleam][prime-factors] reverse inside iter function --- gleam/prime-factors/src/prime_factors.gleam | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gleam/prime-factors/src/prime_factors.gleam b/gleam/prime-factors/src/prime_factors.gleam index b456f48..3bcd877 100644 --- a/gleam/prime-factors/src/prime_factors.gleam +++ b/gleam/prime-factors/src/prime_factors.gleam @@ -1,12 +1,12 @@ import gleam/list pub fn factors(value: Int) -> List(Int) { - list.reverse(factors_iter(value, 2, [])) + factors_iter(value, 2, []) } fn factors_iter(n: Int, i: Int, factors: List(Int)) -> List(Int) { case n, n % i { - 1, _ -> factors + 1, _ -> list.reverse(factors) _, 0 -> factors_iter(n / i, i, [i, ..factors]) _, _ -> factors_iter(n, i + 1, factors) }