Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- //b
- int VeriFib(int n, int p, int p2)
- {
- if(n <= 1)
- {
- if(n == 1) return n;
- else return 0;
- }
- else return VeriFib(n-p, p2, p+p2);
- }
- //c
- int NrDiv(int n, int d, int nrd)
- {
- if(n == 1) return nrd+1;
- else if(n % d == 0) return NrDiv(n/d, d, nrd++);
- else return (nrd+1) * NrDiv(n, d+1, 1);
- }
- //d
- int VeriPrim(int n, int d)
- {
- if(n % d == 0) return 0;
- else if(d * d > n) return 1;
- else return VeriPrim(n, d+1);
- }
- int main()
- {
- cout << VeriFib(21, 1, 1) << "\n\n";
- //cout << NrDiv(12, 2, 1) << "\n\n";
- for(int i = 2; i <= 31; i++) cout << i << " - " << VeriPrim(i, 2) << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement