Computer Science, asked by sridharsiva02, 8 months ago

Write the program to find the sum of the following series

S=a/2+a/5+a/8+a/11+……….+a/20


Answers

Answered by varsha5160
4

Answer:

import java.util.*;

public class Program

{

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("Enter the value for A ");

double input = sc.nextFloat();

double sum=0;

for(int i=2;i<=20;i+=3) // to divide by 2,5,8 so on that is why increase by 3 to i

{

sum+=input/i;

}

System.out.println(sum );

}

}

If you have any question feel free to ask me. :)

no problem :) always ready to share my experience and knowledge

+1

Sure I will just check it out :)

0

I have posted 1 more question can u give the program for that @Giriraj Bhagat

0000

0

I have posted the answers for both of your questions. If you have any querries do let me know

Answered by jai696
2

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

def series(a):

_sum = 0

for i in range(2, 21, 3):

_sum += a / i

return _sum

print("result:", series((a := int(input("a: ")))))

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions