Whats wrong in this code ?--> recursion lexographically

#include <bits/stdc++.h>
using namespace std;
void lexographically(int a,int n){
if(a>n){
return ;
}
cout<<a<<" ";
int i=0;
if(a==0){
i=1;
}
for(;i<n;i++){
lexographically(a*10+i,n);
}
}

int main() {
int n;
cin>>n;

lexographically(0,n);
cout<<endl;
return 0;

}

hi @bhardwajsaksham796,
Similarly Classification acc to the Given prblm :-

  • Bigger Problem : To Print all of the counting from 1 to N.
  • Smaller Problem : Assume the recursion works and will give you ans for counting 2 to N and 3 to N and 4 to N upto 9 to N.
  • Self Work : In order to make you smaller prblm your problem all you need to print your current number and rest will be done by the Smaller work.

refer this code for recursion approach–>