Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
Go
Haskell
HLSL
Hook
Hylo
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Nim
Objective-C
Objective-C++
OCaml
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Solidity
Spice
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
Zig
Javascript
GIMPLE
python source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
PyPy 3.10
PyPy 3.9
Python 3.10
Python 3.11
Python 3.12
Python 3.5
Python 3.6
Python 3.7
Python 3.8
Python 3.9
Pythran 0.15
Options
Source code
print('''This code will eventually relate if a prime number is or is not a Mersenne Prime. The problem is with large numbers and division of factors and so as with Prime numbers starting at 29 the time slows down on input. Anyone who can make this code respond to every prime number of trillions of digits consecutively in less than 4 seconds, that reports back correct statements for prime numbers would become famous and win a Noble Peace Prize!''') print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') print('_________________________________________________') import time from math import floor def divSum(n): total = 1 i = 2 while i * i <= n: if n % i == 0: total += i + floor(n // i) i += 1 return total #def solve(p, q): # return divSum(q) == divSum(q) while True: start_time = time.time() p = int(input("Enter a prime number for an attempt to produce a Mersenne Prime Number: ")) h = (pow(2,p-1)*2-1)*(pow(2,p-1)) m = (((p - 1) % 9 + 1 if p else 0)) q = (pow(2,p-1)*2-1)*(pow(2,p-1)) y = (((q - 1) % 9 + 1 if q else 0)) if (divSum(q))== h: print(p,'= n and this number produces a Mersenne Prime 2^n-1') e = int(time.time() - start_time) print('{:02d}:{:02d}:{:02d}'.format(e // 3600, (e % 3600 // 60), e % 60))
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
About the author
Statistics
Changelog
Version tree