Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 29/12/2015
- --Last update: 23/05/2016
- --[[ Notes:
- Does:
- Retorna um fatorial ou um somatório do número dado.
- Args:
- x --> Número
- t --> Tipo
- 0 --> Fatorial (3 = 1*2*3 = 6)
- 1 --> Somatório (5 = 5+4+3+2+1 = 15)
- ]]--
- math.somarial=function(x,t)
- if x == 1 then return 1 end
- if t == 0 then
- return x * math.somarial(x-1,0)
- elseif t == 1 and x > 0 then
- return x + math.somarial(x-1,1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement