Generation

generate functionFri, 28 Apr 2023

implementar la función sumaPrimerosNImparesEspecial :: Integer ->Integer, cuya especificación es la siguiente: problema sumaPrimerosNImparesEspecial (n: Z) : Z { requiere: {n ≥ 1} asegura: {res = P2n−1 i=1 if (i mod 2 = 0) then 0 else 2 ∗ i + 2 fi} }

sumaPrimerosNImparesEspecial :: Integer -> Integer sumaPrimerosNImparesEspecial n = sum (filter (\x -> mod x 2 /= 0) (map (\x -> 2 * x + 2) [1..n]))

Want to kickstart your project?Use the new AI Studio to create your code