0
Nth term of a series in c++
How can I build a program to find nth term of this series: 1234567890123456...
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..
+ 1
Jayakrishnađźđł thank u but I'm a beginner, can you explain more?
+ 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....
+ 1
Jayakrishnađźđł thank you soo much! it workedd!!