Skip to content

Commit 3e39076

Browse files
authored
Create Product of consecutive Fib numbers.cpp
1 parent 1feff87 commit 3e39076

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <vector>
2+
3+
using namespace std;
4+
5+
typedef unsigned long long ull;
6+
class ProdFib
7+
{
8+
public:static vector<ull> productFib(ull prod);
9+
};
10+
11+
vector<ull> ProdFib::productFib(ull prod)
12+
{
13+
ull f[1000];
14+
f[0] = 0; f[1] = 1;
15+
for ( int i = 2; i < 1000; i++)
16+
{
17+
f[i] = f[i-1] + f[i-2];
18+
if ( f[i]*f[i-1] == prod ) return {f[i-1],f[i],1};
19+
if ( f[i]*f[i-1] > prod ) return {f[i-1],f[i],0};
20+
}
21+
}

0 commit comments

Comments
 (0)