Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- float progression(int n){
- if (n == 0){
- return 1;
- }
- else if (n== 1){
- return 4;
- }
- else
- {
- return 2*progression(n-1) + 0.5*progression(n-2);
- }
- }
- int main(int argc, char *argv[]) {
- int n;
- printf("Podaj n = ");
- scanf("%d", &n);
- printf("a(%d) = %.2f",n,progression(n));
- return 0;
- }
Add Comment
Please, Sign In to add comment