Question: Uses Recursion to calculate 1, 1, 2, 3, 5, 8, 13, and 21 ...... 30th bits!
Effect:
Code:
1 Protected Void Button#click ( Object Sender, eventargs E) 2 { 3 If (Tb1.text! = "" & Tb1.text! = Null ) 4 { 5 If (! Isnum (tb1.text )) 6 { 7 Response. Write ( " <SCRIPT type = 'text/JavaScript '> alert ('Enter the number'); </SCRIPT> " ); 8 } 9 Else 10 { 11 Int A = Convert. toint32 (tb1.text ); 12 Tb2.text = Convert. tostring (FOO ()); 13 } 14 } 15 Else 16 { 17 Response. Write ( " <SCRIPT type = 'text/JavaScript '> alert ('cannot be blank'); </SCRIPT> " ); 18 } 19 } 20 Public Static Int Foo ( Int I) 21 { 22 If (I < 0 ) 23 { 24 Return 0 ; 25 } 26 Else If (I>0 & I <= 2 ) 27 { 28 Return 1 ; 29 } 30 Else 31 { 32 Return Foo (I-1 ) + Foo (I- 2 ); 33 } 34 } 35 Public Static Bool Isnum ( String S) 36 { 37 String Pattern = @" ^ \ D * $ " ; 38 Return RegEx. ismatch (S, pattern ); 39 }