0
2.5kviews
Write the algorithm to find the sum of series and also find its time complexity where


Write the algorithm to find the sum of series and also find its time complexity where

$s=\sum_{i=1}^{n}i2$

1 Answer
0
61views

Our work is to write an algorithm to find the sum of the series and the series is -


$ $ $S = ∑^{n}_{i=1}=i^2$



//Importing the library
import java.util.*;

public class solve {
    public static void main(String[] args) {

        //Taking n as an input
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter …

Create a free account to keep reading this post.

and 2 others joined a min ago.

1

Time complexity will be linear, not constant


Please log in to add an answer.