How I can do Arithmetic progression in c#? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How I can do Arithmetic progression in c#?

Thanks

28th Nov 2018, 1:35 PM
Riki Geula
Riki Geula - avatar
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
28th Nov 2018, 4:49 PM
Bad_Bits
Bad_Bits - avatar
+ 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.
28th Nov 2018, 10:26 PM
David Carroll
David Carroll - avatar