• Inizialmente il calcolo è / At the beginning the calculation is the following:
Quanti tra i mille numeri interi compresi tra 1 e 1000 contengono la cifra 5?
How many of the thousand whole numbers between 1 and 1000 contain the digit 5?
La risposta è / the output is:
271
Il testo del file originale / The original file:
<script> with(Math) { n=0 for(i=0; i<=9; i=i+1) {for(j=0; j<=9; j=j+1) {for(k=0; k<=9; k=k+1) {if(i==5||j==5||k==5) {n=n+1} } } } document.write(n) }</script>
• Se voglio calcolare / If I want calculate:
1) A = 10 2) IF A * 3 > 1000 THEN GOTO 5 3) A = A + 10 4) GOTO 2 5) A = A - 10 6) PRINT A
posso usare / I can use:
<script> with(Math) { a = 10; while (a*3 <= 1000) {a=a+10}; a=a-10 document.write(a) }</script>
per ottenere la risposta 330