Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- //long f(int n){
- // if (n == 0) return 1;
- // return 2 * f(n - 1) + 1 - n % 3;
- //}
- long f1(int n){
- int ans = 1;
- for(int i = 1; i <= n; i++){
- ans = ans*2 + 1 - i%3;
- }
- return ans;
- }
- //long sum(int n) {
- // if (n == 0) return 1;
- // return sum(n-1) + f(n);
- //}
- int main() {
- cout << f1(8) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment