# ZCubes/Mersenne Primes and Perfect Numbers

## Mersenne Primes and Perfect Numbers

Mersenne prime is a prime number that is one less than a power of two. That is, it is a prime number of the form 2n − 1 for some integer n. There are also connected to perfect numbers. The largest known prime number, 282,589,933 − 1, is a Mersenne prime. Finding Mersenne prime and validating it is a computation intensive task. This video demonstrates how to generate Mersenne primes using ZCubes, and will also explore the relationship with Perfect numbers.

## Video

Mersenne Primes and Perfect Numbers

## Code

```a=2n^(1..700);
units.on;
a.\$(x=>[x,x-1n,(ISPRIME(x<>n-1n))])
.filter(r=>r)
```

--> The above code displays the list of Mersenne Prime Numbers for the range upto 700. This calculation deals with large calculations hence an 'n' is added in code for more accuracy.

```1..10000
.filter(n=>SUM(PROPERDIVISORS(n))==n)
```

-->The above code calculates Perfect Numbers in range upto 10,000. Perfect number, a positive integer that is equal to the sum of its proper divisors.This gives the list of numbers 1,6,28,496 and 8,128.

Relationship between Mersenne Primes and Perfect Numbers:
If Mersenne Prime is 'x' then 'x*(x+1)/2' results into the Perfect Number.

```[3,7,31,127,8191,131071].\$("x*(x+1)/2")
```

<< Learn ZCubes