- A+

Category：Languages

How can I solve this math Funcion with Haskell? Can anyone help me?

`myFunc n m = myFuncRec n m if m <= n then 1 else myFuncRec n(m - 1):[] `

Do I need two recursion? because for this problem in java needs two or three loops.

I would normally give a hint instead of a full solution, but since this question is mostly about syntax, and the translation is very close, almost literal, I'll just give it to you in full.

`p n m | m <= n = 1 | otherwise = sum [ p n (m - i) | i <- [1..n] ] `

The bars distinguishing the different cases by conditions are called *guards*, and the bracket structure in the last line is known as a *list comprehension*.