Advertisement
rnort

Task 1

Jul 3rd, 2012
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.19 KB | None | 0 0
  1. #Что выведет данный код на Ruby ?
  2. def f(n)
  3.  if n<0
  4.  (1 - 2*( (1-n)%2 )*f(n)
  5.  elsif n==0 || n==1
  6.  n
  7.  else
  8.   f(n-1)+f(n-2)
  9.  end
  10. end
  11.  
  12. def l(n)
  13.  f(n-1)+f(n+1)
  14. end
  15.  
  16. puts l(-256)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement