Computer Science, asked by alkasingh78206, 16 days ago

wap to print mersenne number (NO. IN THE FOM OF 2 /\-1) read a limit from the user and print all mersenne number until it exceeds the given number also mention the mersenne number which has exceeded the limit. ​

Answers

Answered by r27272278
2

\huge\fcolorbox {magenta} {pink} {★Hey mate here is the answer}

This program prints the series of mersenne numbers till a given number of terms, in JAVA.

PROGRAM -

import java.util.*;

public class MersenneNumberSeries

{

public static void main(String args[])

{

Scanner ob=new Scanner(System.in);

System.out.println("Enter number of terms to be printed.");

int n=ob.nextInt();

System.out.println("The series is-");

for(int i=1;i<=n;i++)

{

int number=(int)Math.pow(2,i)-1;

System.out.print(number+", ");

}

}

}

\huge\fcolorbox {magenta} {violet} {★Hope it helps to you}

\huge\fcolorbox {magenta} {green} {★Thank you}

Similar questions