1. Using recursion to find factorial 5*4*3*2*1
Static int Show (int num)//show (5) { if0) return1 ; Else return num*show (num-1); }
2, Fibonacci series, 1, 1, 2, 3, 5, 8, 13 to find the 30th place
Static intShow (intnum)//Show (+) {if(num = =0|| Num <0) return 0; Else if(num = =1|| num = =2) return 1; Else returnShow (Num-1) + Show (num-2); }
3, Printing triangle inverted (5 lines)
Static intShow (intNum//Show (5) { #region* The Printif(num<0) return; for(inti =0; i < num; i++) {Console.Write ("*"); } Console.WriteLine (); Show (Num-1); #endregion }
4. Bubble sort
Public Static voidShow ()//from big to small{ int[] a={8,4,3,9,Ten, One}; inttemp=0; for(intI=0; i<a.length;i++) { for(intj=0; j<a.length-i-1; j + +) { if(a[j]<a[j+1]) {temp=A[j]; A[J]=a[j+1]; A[j+1]=temp; } } }}
Factorial, Fibonacci sequence, Print triangle (*) recursion, bubble sort