Programming Examples

Python program to print first ten mersenne numbers


Write Python program to print first ten mersenne numbers. Numbers in the form 2n-1 are called Mersenne numbers.

For example, the first Mersenne number is 21-1=1, the second Mersenne number is 22-1=3 etc.

Solution

print("First Ten Mersenne numbers are : ")
for n in range(1,11):
    num=2**n-1
    print(num,end=" ")
Output

First Ten Mersenne numbers are : 

1 3 7 15 31 63 127 255 511 1023 

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz