[50 arithmetic questions] exercises No. 1 rabbit questions every day 50 arithmetic questions

Source: Internet
Author: User

Question:

There was a rabbit who had a rabbit every month since 3rd months after birth. After the third month, the rabbit had a rabbit every month. If the rabbit was not dead, what is the total number of rabbits per month?

ProgramAnalysis: the rabbit rule is a sequence of numbers 1, 1, 2, 3, 5, 8, 13, 21 ....

Bytes ---------------------------------------------------------------------------------------------------------

Here is myCodeYou are welcome to post the results.

C #

   Class  Program {  Static   Void Main ( String  [] ARGs) {thefirst (  10  ); Console. Readline ();} //  [Procedure 1]  //  Question: classical question: there is a rabbit who has given birth to a rabbit every month since 3rd months after birth. After the third month, the rabbit has given birth to another rabbit every month.  //  For rabbits, if they do not die, how many rabbits are there each month?  //  1. program analysis: the rabbit rule is a sequence of numbers 1, 1, 2, 3, 5, 8, 13, 21 ....          Private   Static   Void Thefirst ( Int  Month ){  Int Num =1  ;  For ( Int I = 1 ; I <= month; I ++ ){  If (I> 2  ) {Num ++ ; Createtu (I - 2 , Ref  Num);} console. writeline ( "  Month {0}: {1}  "  , I, num );}}  Private   Static   Void Createtu ( Int Month, Ref   Int  Num ){  For ( Int I = 1 ; I <= month; I ++){  If (I> 2  ) {Num ++ ; Createtu (I - 2 , Ref  Num );}}} 

JS version

<Script language = "JavaScript" type = "text/JavaScript"> VaR Num = 1 ;  Function Thefirst (month ){  For ( VaR I = 1; I <= month; I ++ ){  If (I> 2 ) {Num ++ ; Createtu (I -2 );} Document. Body. innerhtml + = "+" + I + "month:" + num + "+" </BR>" ;}}  Function  Createtu (month ){  For (VaR I = 1; I <= month; I ++ ){  If (I> 2 ) {Num ++ ; Createtu (I -2 );}}} </SCRIPT>

 

For more questions, see 50 arithmetic questions.

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.