Skip to content

Instantly share code, notes, and snippets.

@thmain
Created January 20, 2021 03:42
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/c60f02f0611bf9bfb6970d07b6d194f6 to your computer and use it in GitHub Desktop.
Save thmain/c60f02f0611bf9bfb6970d07b6d194f6 to your computer and use it in GitHub Desktop.
public class ArithmeticProgressionNthTerm {
public static void printAPNthTerm(int a, int d, int n){
System.out.println("a = " + a +", d = " + d + ", n = " + n);
int term = a + (n-1)*d;
System.out.println(n + "th term: " + term);
}
public static void main(String[] args) {
printAPNthTerm(1, 2, 5);
printAPNthTerm(2, 5, 4);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment