Write a program in bluej a to print the series s= 2! + 5! + 8! ..... n ! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Write a program in bluej a to print the series s= 2! + 5! + 8! ..... n !

it is a series program

17th Aug 2018, 12:38 PM
Trisha Jhunjhunwala
Trisha Jhunjhunwala - avatar
1 Answer
+ 1
import java.util.Scanner; public class Series { public static void main( String args[] ) { Scanner sc = new Scanner(System.in); //Enter a number long n = sc.nextLong(); long s = 0; for(long i = 2 ; i<=n ; i+=3) { long f = 1; //Reset the value of f //Calculate factorial of the new number for (long x = 1 ; x<=i ; x++) f *= x ; s += f ; } System.out.println(s); } } You can use BufferedReader instead of Scanner for input. Hope it helps!!👍☺️ Please up vote...
20th Aug 2018, 7:51 AM
Om Raj
Om Raj - avatar