Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int literaDwa(int n)
- {
- if (n <= 0)
- {
- return 0;
- }
- else
- {
- int[] literaDwa = new int[n + 1];
- for (int i = 1; i <= n; i++)
- {
- if (i <= 3)
- {
- literaDwa[i] = i-1;
- }
- else
- {
- literaDwa[i] = (literaDwa[i - 1]) + literaDwa[i - 2] -2;
- }
- }
- return literaDwa[n];
- }
- }
- public static int rekuDwa(int n)
- {
- if (n <= 0)
- {
- return 0;
- }
- else
- {
- if (n <= 3)
- {
- int wynik = n-1;
- return wynik;
- }
- else
- {
- return (rekuDwa(n - 1)) + rekuDwa(n - 2)-2;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement