aboutsummaryrefslogtreecommitdiff
path: root/Homework3/recursive.cpp
blob: 802d64eaf6ab5aea9a62bdf0a66385397044e28f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "recursive.h"



long factorial(long a)
{
	if (a == 1 || a == 0) return 1;
	//size_t appropiate
	return a * factorial(a - 1);

}

size_t fibonacci(size_t a) {
//size_t appropiate
	if (a == 1 || a == 0) {
		return a;
	}
	else {
		return (fibonacci(a - 1) + fibonacci(a - 2));
	}

}

long powerfunction(long a, long b) {
	
	if (b == 0)
	{
		return 1;
	}
	else
	{
		return(a * powerfunction(a, b - 1));
		//size_t appropiate
	}
}