-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
43 lines (38 loc) · 1.22 KB
/
main.cpp
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
36
37
38
39
40
41
42
43
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <functional>
#include <locale>
#include "BigNumber.h"
//using namespace std;
int main(){
///fact
setlocale( LC_ALL,"Russian" );
cout <<"Âû÷èñëåíèå ôàêòîðèàëà èòåðàòèâíûì ñïîñîáîì: "<<fact1(5)<< endl;
cout <<"Âû÷èñëåíèå ôàêòîðèàëà ðåêóðñèâíûì ñïîñîáîì: "<<fact2(5)<< endl;
int Lambda_fact = [] (int N) {
if (N < 0)
return 0;
if (N == 0)
return 1;
int result = 1;
for (int i = 1; i<= N ; i++) {
result *= i;}
return result;}(5);// znachenie
cout <<"Âû÷èñëåíèå ôàêòîðèàëà ñ ïîìîùüþ ëÿìáäà-ôóíêöè: "<< Lambda_fact << endl<<endl;
///fibon
cout<< fibonach(5)<<"end-"<<endl;
cout<<"5-å ÷èñëî Ôèáîíà÷÷è: "<<fibonacci(5)<<endl;
int Lambda_fibon = [] (int n) {
int fib = 1;
int fib2= 1;
while (fib<n) {
fib = fib + fib2;
fib2 = fib - fib2; }
return(fib);}(5);// znachenie
cout <<"Ðåçóëüòàò âû÷èñëåíèÿ ÷èñëà Ôèáîíà÷÷è ëÿìáäà-ôóíêöèåé: "<< Lambda_fibon << endl;
return 0;
}
};