-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnature.html
More file actions
41 lines (29 loc) · 796 Bytes
/
nature.html
File metadata and controls
41 lines (29 loc) · 796 Bytes
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
<!DOCTYPE html>
<html>
<head>
<script>
var a1a1=0.15;
var a2a2=0.35;
var a1a2=1-(a1a1+a2a2);
var p=a1a1+a1a2/2;
var q=1-p;
function round_number(value,decimals){
var shifter=Math.pow(10,decimals);
return Math.round(value*shifter)/shifter;
}
console.log("generation 0:",round_number(a1a1,2),round_number(a1a2,2),round_number(a2a2,2));
//calculating next generation
function create_next_generation(){
a1a1=p*p;
a1a2=2*p*q;
a2a2=q*q;
}
for(var i=0;i<10;i++){
create_next_generation();
console.log("generation "+(i+1)+":",round_number(a1a1,2),round_number(a1a2,2),round_number(a2a2,2));
}
</script>
</head>
<body>
</body>
</html>