JavaScript Basics (Typical examples of the number of young rabbits and rabbits)

Source: Internet
Author: User

The thickness of a piece of paper is 0.0001 meters, fold the paper, fold how many times the thickness exceeds the height of Everest 8848 meters

var sum=0;var a=0.0001for (var i=0;i<100;i++) {a=a*2;sum=sum+1;if (a>=8848) {break;}} Alert (SUM)

  

There are a pair of young rabbits, the young rabbit 1 months later grow into a rabbit, the rabbit 1 months later into a rabbit and give birth to a pair of young rabbits, asked 6 months after how many pairs of rabbits, rabbits, rabbits, Cheng logarithm of how many. Because of the number of rabbits for the next month, the rabbit was the number of young rabbits last month, and the rabbit was added to the rabbit for the rabbits last month, so two variables were defined to receive the number of rabbits and rabbits in the last month.

var a=1;var b=0;var C=0;var M=0;var n=0;for (var x=1;x<=6;x++) {n=c;c=b+c;m=b;b=a;a=m+n;} Alert (A + "," +b+ "," +c ")

  

Badminton Racket 15 Yuan, the ball 3 yuan, the water 2 yuan. $200 each at least one, 200 dollars just spent, how much could

var sum=0;for (Var x=1;x<=13;x++) {for (Var y=1;y<=66;y++) {for (Var z=1;z<=100;z++) {var c=15*x+3*y+2*z;if (c== () {   // remember to use = =   = to represent assignment     sum++;}  //sum++  and sum=sum++ The   latter is the first assignment and then + +          }           }     }alert (sum);     //Because when defining a variable, x, Y, Z are equal to 1 so that each of at least one of these conditions is met

 

Rooster 2, hen 1, chicken half, each of at least one, 100 buy 100 chickens how many possibilities

var sum=0;for (Var x=1;x<50;x++) {for (Var y=1;y<100;y++) {for (Var z=1;z<200;z++) {var a=2*x+y+0.5*z;var b=x+y+z ; if ((a==100) && (b==100)) {Sum++}}}}alert (sum);

  

Pooled 1,2,5 20 Yuan money how many possible

var sum=0;  for (Var x=1;x<=20;x++) {for (  var y=1;y<=10;y++) {for  (var z=1;z<=5;z++) {  var a=x+2*y+5*z;  if (a==20) {  sum++}}}}  alert (sum)   

  

JavaScript Basics (Typical examples of the number of young rabbits and rabbits)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.