1. Number related to 7 within output 100
function num(a){ for(var i=1;i<=100;i++){ if (i%a==0||parseInt(i/10)==a||(i%10)==a) { document.write(i+'<br>'); } } } num(7);
2. Output all numbers from 1 to 100 that cannot be divided by 3; and output the sum of these integers
function show(b){ var sum=0; for(var i=1;i<=100;i++){ if (i!=(i%b==0)){ sum+=i; } } console.log('As for'+sum); } show(3);
3. Make a small game, report the safety number of Game 7 (report in turn, report can be divided by 7 or the ending number is 7, perform the program), report the safety number between 1-100
function game(c){ for(var i=1;i<=100;i++){ if (i%c==0||(i%10)==c) { continue; } document.write(i+'<br>'); } } game(7);
4. Print the number of daffodils (three digits), (153 = 1111 + 555 + 33 * 3) the sum of the cubes of each digit is equal to the number, that is, the number of daffodils, and print out all the number of daffodils.
function sum(i){ for(var i=100;i<1000;i++){ var a=i%10; var b=(i%100-a)/10; var c=parseInt(i/100); num=c*c*c+b*b*b+a*a*a; if (i==num) { document.write(i+'<br>'); } } } sum();
5. Find the factorial of 10
function sum(i){ var sum=1; for(var i=1;i<=10;i++){ sum*=i; } document.write(sum); } sum(10);
6. Everest is 8848 meters above sea level. Now there is enough paper with a thickness of 0.01 meters. How many times can it be folded higher than Everest.
function num(height){ var count=0;//Statistics times var totalHeight=884800;//Altitude while(height<=totalHeight){ height*=2; count++;//Counter change //if (height>=totalHeight) { //break; //} } return count; } var count=num(1); console.log('Fold'+count+'second');
7. Print the following figure
// * // *** // ***** // ******* // *********
function yao(i){ for(var i=1;i<5;i++){ //Output one line* for(var j=1;j<=2*i-1;j++){ document.write('*'); } document.write('<br>'); } } yao(5);