Tricky Sequence Question

yes, because, i have appended upto 500 only, so that we can not get the index of the next integer., and i am giving output as “index out of bound” in such situations

@rajasekharcool and @sumanth_puri can you please specify why you down voted my answer, is there problem in description or is it only because I down voted your slow solutions?

I’m just saying if @toiletpaper do not specify otherwise for me limit like 1500 is not good enough…

On my PC code for input 100.000 (10^5) and 480.000 (48*10^4) returns answer in 15 seconds.

because…, i am unable to estimate the running time with ur description., so if u provide ur code., we can try to do…

using namespace std;
int fun(int a){
if(a<=9)return a;
int i,s=0;
int k=a-s+((pow(10,i)-pow(10,i-1))*i);
int no=floor((float)k/i);
int val=pow(10,i-1)-pow(10,i-2);
int c=k%i;

return k;

main(){int a;
cout<<"enter index:"<<endl;
cout<<"digit is:"<<fun(a)<<endl;


This one is not working, maybe you can describe your approach, but expected result for inputs 1393, 1394 and 1395 is 5, 0 and 1, your code returns 1, 4, 9 -

I added the link to my algorithm :wink:

I added the link to my algorithm :wink: It runs for 10^18 in less than 0.1s

I added link to the algorithm, it can find the result for 10^18 in less than 0.1s :wink:

index = [0,10^18]

@betlista : excellent answer

1 Like

@betlista: extra ordinary