2024_3

gorazd avatar
gorazd
C++
01/12/2025 4:14 PM
506 B
18
Indexable
Never
#include <iostream>
#include <cctype>
#include <cstring>
#include <iomanip>
using namespace std;


void sequence(int n, int i, bool descendI)
{
    if(n - 5*i <= 0)
        descendI = true;
    if(descendI and i == 0)
    {
        cout<<n;
        return;
    }
    if(!descendI)
    {
        cout<<n-5*i<<" ";
        sequence(n, i+1, descendI);
    }
    else
    {
        cout<<n-5*i<<" ";
        sequence(n, i-1, descendI);
    }
}

int main() {
    int n;
    cin>>n;
    sequence(n, 0, false);
}
Editor is loading...
Leave a Comment