Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int potegadwojki (int n)
- {
- if(n==0)
- {
- return 1;
- }
- else
- {
- return 2*(potegadwojki(n-1));
- }
- }
- int funkcja(int n)
- {
- if(n==0)
- {
- return 0;
- }
- if(n%2!=0)
- {
- if(n==0)
- {
- return 1;
- }
- else
- {
- return potegadwojki(n);
- }
- }
- if(n%2==0)
- {
- return (funkcja(n-1) - funkcja(n-2));
- }
- }
- int main()
- {
- int n;
- printf("Podaj n: ");
- scanf("%d",&n);
- printf("Wartosc funkcji dla %d wynosi: %d",n,funkcja(n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement