1 package jrre.unittests.datastructures;
2
3 public class Algorithems {
4
5 public int add(int a, int b) {
6 return a + b;
7 }
8
9 public int sub(int a, int b) {
10 return a - b;
11 }
12
13 public int mul(int a, int b) {
14 return a * b;
15 }
16
17 public int div(int a, int b) {
18 return a / b;
19 }
20
21 public int euclidsGCD(int u, int v){
22 if(v == 0)
23 return u;
24 else
25 return euclidsGCD(v, u-u/v*v);
26 }
27
28 public int factorial(int number){
29
30 if(number == 1)
31 return 1;
32 else
33 return(number * factorial(number-1));
34 }
35
36 public int fibonacci(int number){
37
38 if(number <= 0)
39 return 0;
40 if(number <= 2)
41 return 1;
42 else
43 return fibonacci(number-1) + fibonacci(number-2);
44 }
45
46 public static void main(String [] args){
47
48 Algorithems a = new Algorithems();
49 a.fibonacci(6);
50 //jrre.api.java.lang.System.out.println(a.fibonacci(5));
51 }
52 }
53
This page was automatically generated by Maven