Added 3byte prime numbers

This commit is contained in:
ZAKS Web 2024-12-20 20:15:01 +02:00
parent 580218a265
commit 69ae3f72fb
5 changed files with 1078227 additions and 0 deletions

View File

@ -0,0 +1,57 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>The complete list of primes.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="author" content="Luis Silvestre">
<link rel="stylesheet" type="text/css" href="calculate-primes.html.css">
<!--
It is javascipt. What else were you expecting?
Author: Luis Silvestre
-->
<script type="text/javascript">
function isPrime(_n)
{
var _isPrime=true;
var _sqrt=Math.sqrt(_n);
for(var _i=2;_i<=_sqrt;_i++)
if((_n%_i)==0) _isPrime=false;
return _isPrime;
}
function li(_o)
{
var _n=i + 100;
var what="";
for(;i<_n;++i){
if(isPrime(i)){
what += i.toString()+"; ";
}
}
document.getElementById("texto").firstChild.nodeValue = what;
//appendChild(mytext);
}
</script>
</head>
<body>
<div class="orangebox">
<p> In this website we list <b> all </b> prime numbers. Every single one of them. <a href="javascript:li()"> Next page. </a></p>
</div>
<div id="texto" class="whitebox" style="height:100000px; border:0px;">
If you can read this, that means that your browser has javascript off and this page is not working.
</div> <br />
<script type="text/javascript">
i =4294967200;
li();
</script>
<div class="orangebox"> <a href="javascript:li()"> Next page. </a> </div>
</body>
</html>

View File

@ -0,0 +1,96 @@
body {
font:100% Sans-Serif,Helvetica,Verdana,Tahoma;
background-color:#DDDDDD;
/*background-image: url('icons/background2.png');
background-repeat: repeat*/
}
/*<-- background-image:
url('icons/background.png');
background-repeat: repeat -->*/
h2 {font-size:2.5em}
a {text-decoration:none; color:#003030; font-weight:bold}
a:hover {color:purple; font-weight:bold}
img {border: none; vertical-align:middle}
p {vertical-align:middle}
#mainbox {border-width:0px; margin:2px; text-align:left; min-height:413px; padding-left:15px;background-color:white;}
.header {height:50px; font-weight:bold; font-size: 200%; vertical-align:middle;}
#additionaltools {float:right; border-style:dotted; padding:1px;background-color:white; width:260px;}
#membrete {position: absolute; top: 10px; left:500px}
.photo {float:right;}
.fakelink {color:teal; font-weight:bold}
.description {padding-left: 40pt;}
.orangebox {border-width:0px; background-color: #FFEECC; margin:15px; padding: 5px; text-align:left;}
.MathTeX {display:none; background-color: #FFEECC;}
.whitebox {
font:100% Sans-Serif,Helvetica,Verdana,Tahoma;
border-width:0px;
background-color: white;
margin:15px;
padding: 5px;
text-align:left;
}
/* Title Bar - stolen from somewhere
===================================== */
h1
{
margin: 0;
background-color: #333333;
}
h1 a
{
display: block;
padding: 30px 20px;
border-top: 1px solid #9e2121;
border-bottom: 1px solid #4a0404;
text-align: center;
/* These are all various ways of setting the background color, */
/* designed so that at least one will work on any browser */
background-color: #7d0101;
background: -moz-linear-gradient(top, #7d0101 0%, #651110 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #7d0101), color-stop(100%, #651110));
background: -webkit-linear-gradient(top, #7d0101 0%, #651110 100%);
background: -o-linear-gradient(top, #7d0101 0%, #651110 100%);
background: -ms-linear-gradient(top, #7d0101 0%, #651110 100%);
background: linear-gradient(top, #7d0101 0%, #651110 100%);
}
h1 a, h1 a:hover
{
color: #ffffff;
text-decoration: none;
}
#title-left
{
padding: 11px 0;
}
#title-right img
{
height: auto;
width: auto;
vertical-align: middle;
}

View File

@ -0,0 +1,63 @@
import numpy as np
import time
import os
def clear_terminal():
"""Clear the terminal screen."""
os.system('cls' if os.name == 'nt' else 'clear')
def sieve_of_eratosthenes(limit):
"""Sieve of Eratosthenes to find all primes up to 'limit'."""
sieve = np.ones(limit // 3 + (limit % 6 == 2), dtype=bool)
sieve[0] = sieve[1] = False # 0 and 1 are not prime
# Iterate only for numbers that are prime
for i in range(1, int(limit**0.5) // 3 + 1):
if sieve[i]:
prime = 3 * i + 1
sieve[3 * i + prime::prime * 3] = False
primes = [2, 3]
for i in range(1, len(sieve)):
if sieve[i]:
primes.append(3 * i + 1)
return primes
def write_prime_to_file(prime, filename):
"""Write the hexadecimal and decimal representation of a prime number to the file."""
hex_prime = f"{prime:08X}" # Convert to hex with leading zeros (8 digits)
with open(filename, 'a') as f: # Open in append mode
f.write(f"{hex_prime} {prime}\n")
def main():
limit = 4294967295
filename = 'primes.txt'
# Start the sieve calculation and time it
start_time = time.time()
total_primes = 0
for prime in sieve_of_eratosthenes(limit):
total_primes += 1
write_prime_to_file(prime, filename)
# Clear the terminal and update information
clear_terminal()
elapsed_time = time.time() - start_time
estimated_time_left = (elapsed_time / total_primes) * (len(primes) - total_primes) if total_primes > 0 else 0
# Print the last prime, elapsed time, estimated time left, and total primes found
print(f"Last Prime Found: {prime}")
print(f"Total Primes Found: {total_primes}")
print(f"Elapsed Time: {elapsed_time:.2f} seconds")
print(f"Estimated Time Left: {estimated_time_left:.2f} seconds")
# Print final completion message
print(f"Finished calculating primes up to {limit}.")
print(f"Total Primes Found: {total_primes}")
print(f"Total Elapsed Time: {elapsed_time:.2f} seconds")
if __name__ == "__main__":
main()

32
code-files/convert.sh Normal file
View File

@ -0,0 +1,32 @@
#!/bin/bash
maxint=9223372036854775807
root=3037000499
destination=4294967295
rm -f prime.list
SECONDS=0
n=0
echo "Counting number of primes..."
size=$(cat source.list | wc -l)
echo "00000001 1" >> prime.list
while read -r prime; do
hex=$(printf "%08X" "${prime:0:-1}")
echo "$hex $prime" >> prime.list
if [[ $((n%100)) == 0 ]]; then
clear
rate=$((SECONDS*1000000/(n+1)))
estsec=$((rate*size/1000000))
remsec=$((estsec-SECONDS))
echo "Running Time: $((SECONDS/86400)) days, $(((SECONDS%86400)/3600)) hours, $(((SECONDS%3600)/60)) minutes and $(((SECONDS%60))) seconds..."
echo "Remaining Time: $((remsec/86400)) days, $(((remsec%86400)/3600)) hours, $(((remsec%3600)/60)) minutes and $(((remsec%60))) seconds..."
echo "Processed $n of $size PRIME numbers at an average rate of $((n/(SECONDS+1))) per second..."
echo "Latest Prime Number: $prime"
echo "Destination Number: $destination [$((n*100/size)) %]"
fi
((n++))
done < source.list

File diff suppressed because it is too large Load Diff