1 2 function gogo() {3 var log = document.getElementById('log');4 5 var w = 1;6 var m = 100000;7 8 var center = 09 , min = 010 , max = 0;11 12 for (var i = 0; i<m; i++) {13 var r = Math.floor(Math.random()*2);14 r==0 ? w *= 10 : w /= 10;15 r==0 ? center++ : center--;16 17 min = Math.min(min,center);18 max = Math.max(max,center);19 }20 21 log.innerHTML = 'Result: '+w+' (min='+min+', max='+max+')';22 }23 24 function f() {25 var table = document.getElementById('f');26 var canvas = document.getElementById('canvas');27 var ctx = canvas.getContext("2d");28 29 30 31 //var n = 2;32 33 for (var d = 1; d<400; d+=1) {34 var row = '';35 row += '<tr>';36 row += '<td>'+d+'</td>';37 for (var n = 2; n < 800; n++) {38 var m1 = 1;39 for (var i=1; i<d; i++) {40 m1*=n;41 }42 for (var i=1; i<d; i++) {43 m1/=n;44 }45 if (m1 == Infinity) {46 m1 = 'INFINITO';47 ctx.fillStyle="#000000";48 } else if (m1<1) {49 m1 = 'ROJO';50 ctx.fillStyle="#FF0000";51 } else {52 m1 = 'VERDE';53 ctx.fillStyle="#00AA00";54 }55 ctx.fillRect(n,d,1,1);56 row += '<td>'+m1+'</td>';57 }58 row += '</tr>';59 //table.innerHTML += row;60 }61 }
Este ShareCode tiene versiones:
- 0 Go go ! Floating ... (24/04/2013)
- 0 Go go ! Floating ... (24/04/2013)
- 0 Go go ! Floating ... (24/04/2013)
- 0 Go go ! Floating ... (24/04/2013)
Enlace
El enlace para compartir es: