Computer Science, asked by Amankkanwar117, 9 months ago

Find the sum of the series: a2+a5+a8+a11...an. Using Java for loops. As soon as possibble...plzzz

Answers

Answered by debayudhbasu
1

Answer:

import java.util.*;

class loop

{

public static void main()

{

Scanner sc= new Scanner(System.in);

int n=sc.nextInt();

int a=sc.nextInt();

int i,s=0;

for(i=2;i<=n;I+=3)

s=s+a*i;

System.out.println(s);

}

}

Similar questions