0

Nth term of a series in c++

How can I build a program to find nth term of this series: 1234567890123456...

19th Mar 2021, 7:26 PM
Sahaarr
Sahaarr - avatar
4 Answers
+ 1
Use a loop, i=1 to n , nth term n%10, print it. simple. What you tried so far.. post your try..! If not solved..
19th Mar 2021, 7:31 PM
Jayakrishna 🇼🇳
+ 1
Jayakrishna🇼🇳 thank u but I'm a beginner, can you explain more?
19th Mar 2021, 7:34 PM
Sahaarr
Sahaarr - avatar
+ 1
Have you completed any loop topic in lesdons..? If not then just do it. You can understand it. Series is just digits 0 to 9 repeating starting from 1 . 1st number is 1 2nd number is 2. ... 9 th is 9 10 th is 0 11th is 1.. (repeating) Nth number is n%10. (Returns last digit.. 100th number is 100%10=0 for(int i=1; ; i++) { if(i==n) { cout<<n%10; break; } } It runs i= 1 to n , and if block prints nth number and breaks loop.. you can use while loop here for easily understandings....
19th Mar 2021, 7:43 PM
Jayakrishna 🇼🇳
+ 1
Jayakrishna🇼🇳 thank you soo much! it workedd!!
19th Mar 2021, 7:46 PM
Sahaarr
Sahaarr - avatar