File tree 3 files changed +111
-0
lines changed
3 files changed +111
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ This piece of code was made by Grzegorz Skornowicz
3
+ You can contact me at [email protected]
4
+ You can clone this code from GIT repository under link:
5
+ This software is free to use by anybody
6
+ May The Force Be With You !!!
7
+ */
8
+
9
+ #include < iostream>
10
+
11
+ using namespace std ;
12
+
13
+ int euclideanAlghorithm (int a, int b)
14
+ {
15
+ int c;
16
+ while (b != 0 )
17
+ {
18
+ c = a % b;
19
+ a = b;
20
+ b = c;
21
+ }
22
+ return a;
23
+ }
24
+
25
+
26
+ int main ()
27
+ {
28
+ int a, b;
29
+
30
+ cout << " Greatest common divisor (GCD) using Euclides modulo alghoritm" << endl;
31
+ cout << " This piece of code was written by Grzegorz Skornowicz index nr 5899" << endl;
32
+ cout << " =============================================================" << endl;
33
+ cout << " Please type in two integer a & b numbers to look for GCD of theese numbers" << endl;
34
+ cin >> a >> b;
35
+ cout << " Greatest common divisor of numbers "
36
+ << a << " and " << b << " is " << euclideanAlghorithm (a, b) << endl;
37
+
38
+ return 0 ;
39
+ }
40
+
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ using namespace std ;
4
+
5
+ unsigned long int FibRecur (int n)
6
+ {
7
+ if (n <= 1 ) return n;
8
+ else return FibRecur (n-1 ) + FibRecur (n-2 );
9
+ }
10
+
11
+ int main ()
12
+ {
13
+ int n;
14
+ cin >> n;
15
+ cout << FibRecur (n) << endl;
16
+ system (" pause" );
17
+ return 0 ;
18
+ }
19
+
Original file line number Diff line number Diff line change
1
+ /*
2
+ This piece of code was made by Grzegorz Skornowicz
3
+ You can contact me at [email protected]
4
+ You can clone this code from GIT repository under link:
5
+ This software is free to use by anybody
6
+ May The Force Be With You !!!
7
+ */
8
+
9
+ #include < iostream>
10
+ #include < iomanip>
11
+
12
+ using namespace std ;
13
+
14
+ void fibnumber (int n)
15
+ {
16
+ long double *p;
17
+ p = new long double [n];
18
+ if (n == 0 ) cout << " 0" ;
19
+ else if (n == 1 ) cout << " 1" ;
20
+ else
21
+ {
22
+ p[0 ] = 0 ;
23
+ p[1 ] = 1 ;
24
+ for (int i = 2 ; i <= n; i++)
25
+ {
26
+ p[i] = p[i - 1 ] + p[i - 2 ];
27
+ }
28
+ for (int i = 0 ; i <= n; i++)
29
+ {
30
+ cout << i << " - " << p[i] << " \n " ;
31
+ }
32
+ }
33
+ // delete [] p; // FIX dynamic allocation heap error after delete of array???
34
+ }
35
+
36
+
37
+ int main ()
38
+ {
39
+ int n;
40
+
41
+ cout << " Fibonacci number function to n place" << endl;
42
+ cout << " This piece of code was written by Grzegorz Skornowicz index nr 5899" << endl;
43
+ cout << " =============================================================" << endl;
44
+ cout << " please type in n number, n marks how many fibonnaci numbers you want to get." << endl;
45
+ cin >> n;
46
+ cout << fixed;
47
+ cout << setprecision (0 );
48
+ fibnumber (n);
49
+
50
+ system (" pause" );
51
+ return 0 ;
52
+ }
You can’t perform that action at this time.
0 commit comments