Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public static int literaDwa(int n)
  2. {
  3. if (n <= 0)
  4. {
  5. return 0;
  6. }
  7. else
  8. {
  9. int[] literaDwa = new int[n + 1];
  10. for (int i = 1; i <= n; i++)
  11. {
  12.  
  13. if (i <= 3)
  14. {
  15. literaDwa[i] = i-1;
  16. }
  17. else
  18. {
  19. literaDwa[i] = (literaDwa[i - 1]) + literaDwa[i - 2] -2;
  20. }
  21. }
  22. return literaDwa[n];
  23. }
  24.  
  25. }
  26. public static int rekuDwa(int n)
  27. {
  28. if (n <= 0)
  29. {
  30. return 0;
  31. }
  32. else
  33. {
  34. if (n <= 3)
  35. {
  36. int wynik = n-1;
  37. return wynik;
  38. }
  39. else
  40. {
  41. return (rekuDwa(n - 1)) + rekuDwa(n - 2)-2;
  42. }
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement