WAP to print the 2,5,8, 11, 14 series and
also sum of this numbers.
Answers
Answered by
4
Answer:
The answer is
// Java Program to print an arithmetic
// progression series
class GFG
{
static void printAP(int a, int d, int n)
{
// Printing AP by simply adding d
// to previous term.
int curr_term;
curr_term=a;
for (int i = 1; i <= n; i++)
{ System.out.print(curr_term + " ");
curr_term =curr_term + d;
please mark as brainliest answer.
}
}
// Driver code
public static void main(String[] args)
{
// starting number
int a = 2;
// Common difference
int d = 1;
// N th term to be find
int n = 5;
printAP(a, d, n);
}
}
Similar questions