Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function F (i)
- if i == 1 then
- return 0
- elseif i == 2 then
- return 1
- elseif i > 2 then
- return F(i-2) + F(i-1)
- end
- end
- print("Entre com o número de um dos termos da série de Fibonacci:")
- i=io.read("*n")
- print("Valor correspondente na série de Fibonacci:")
- print(F(i))
- function C (n,k)
- if k==0 or n==k then
- return 1
- elseif n>k and k>0 then
- return C(n−1,k) + C(n−1,k−1)
- end
- end
- print("Entre com valores para n e k:")
- local n,k=io.read("*n","*n")
- print("O coeficiente é:")
- print (C(n,k))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement