+ 3
How I can do Arithmetic progression in c#?
Thanks
2 Answers
+ 3
Input following parameters from user
1. First term = a
2. Common Difference = d
3. Number of terms to display = t
Define a variable
nth_term
Make a loop like this
for(i=1;i<=t;i++){
nth_term = a + (i-1)*d ;
//Print it or store in an array
}
This loop will generate all members of that ap
I hope this will give you an Idea
+ 1
Here's my version of doing Arithmetic Progression in C#.
https://dotnetfiddle.net/WYXUlg
If you just want the simplified code, look at the ArithmeticProgression class.
The Program class shows usage and contains formatted output code to show the results.
NOTE: This doesn't always work in SoloLearn Code Playground:
https://code.sololearn.com/cgINi7anxvzh/?ref=app
It sometimes show a "Compilation error" on Code Playground and other times will work in the desktop browser.