Advertisement
rafid_shad

series

Jan 27th, 2019
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.34 KB | None | 0 0
  1.  
  2. package Factorial;
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class series {
  7.     public static void main(String[] args) {
  8.         Scanner ss= new Scanner(System.in);
  9.         int n=ss.nextInt();
  10.         int sum=0;
  11.         for (int i = 1; i <= n; i+=2) {
  12.             sum+=i*i;
  13.         }
  14.         System.out.println("sum is = "+sum);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement