Skip to content

Instantly share code, notes, and snippets.

@thmain
Created January 20, 2021 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/0660a62e42ff351addc3b754bfcf6f90 to your computer and use it in GitHub Desktop.
Save thmain/0660a62e42ff351addc3b754bfcf6f90 to your computer and use it in GitHub Desktop.
public class ArithmeticProgressionSeries {
public static void printAP(int a, int d, int n){
System.out.println("a = " + a +", d = " + d + ", n = " + n);
for (int i = 1; i <=n ; i++) {
int term = a + (i-1)*d;
System.out.print(term + " ");
}
System.out.println();
}
public static void main(String[] args) {
printAP(1, 2, 5);
printAP(2, 5, 7);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment