-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
59 lines (50 loc) · 1.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" charset="utf-8" src="processing-0.9.7.js"></script>
</head>
<body>
<div id="display">
<script type="application/processing">
int x = 1;
int lastPrime = 0;
void setup() {
size(10000,450);0
background(10);
stroke(250);
frameRate(1000);
}
void draw() {
stroke(250);
int width = 5;
int height = (x - lastPrime) * 10;
rect((x * width) - 1, 449 - height, width, height);
x++;
if(isPrime(x)) {
lastPrime = x;
}
stroke(0);
fill(0);
rect(0,0, 200, 75);
fill(250);
text(frameRate, 0,0, 200, 75);
if(x > 2000) {
exit();
}
}
boolean isPrime(int number) {
int upperBound = ceil(sqrt(number));
for(int i = 2; i < upperBound; i++) {
if(number % i == 0) {
return false;
}
}
return true;
}
</script>
<canvas width="10000" height="450"></canvas>
</div>
<p>Displaying distances between primes... y = x - [nearest prime number preceding x]</p>
<script type="text/javascript" charset="utf-8" src="processing.init.js"></script>
</body>
</html>