Serie08
This commit is contained in:
		| @@ -1,7 +0,0 @@ | ||||
| package C12_Recursivite; | ||||
|  | ||||
| public class App { | ||||
|     public static void main(String[] args) throws Exception { | ||||
|         System.out.println("Hello, World!"); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										14
									
								
								src/Series/S08/S08EX01b.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/Series/S08/S08EX01b.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| package Series.S08; | ||||
|  | ||||
| public class S08EX01b { | ||||
|     public static void main(String[] args) { | ||||
|         System.out.println("Result: " + f2(6,5)); | ||||
|     } | ||||
|  | ||||
|     static int f2(int x, int y){ | ||||
|         if (x <= 0) return 0; | ||||
|         if (y >= x) return 1 + f2(y,x); | ||||
|  | ||||
|         return 2 + f2(x-3,y-1); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										14
									
								
								src/Series/S08/S08EX02a.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/Series/S08/S08EX02a.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| package Series.S08; | ||||
|  | ||||
| public class S08EX02a { | ||||
|     public static void main(String[] args) { | ||||
|         int n = 5; | ||||
|         System.out.println("Factoriel de " + n + " = " + fact(n)); | ||||
|     } | ||||
|  | ||||
|     static long fact(int n){ | ||||
|         if (n <= 1) return 1; | ||||
|          | ||||
|         return n*fact(n-1); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										17
									
								
								src/Series/S08/S08EX02b.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/Series/S08/S08EX02b.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| package Series.S08; | ||||
|  | ||||
| public class S08EX02b { | ||||
|     public static void main(String[] args) { | ||||
|         int x = 2; | ||||
|         int n = 8; | ||||
|  | ||||
|         System.out.println(x + " puissance " + n + " = " + power(x, n)); | ||||
|     } | ||||
|  | ||||
|     static long power(int x, int n){ | ||||
|         if (n <= 0) return 1; | ||||
|         if (n == 1) return x; | ||||
|  | ||||
|         return x * power(x, n-1); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										17
									
								
								src/Series/S08/S08EX02c.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/Series/S08/S08EX02c.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| package Series.S08; | ||||
|  | ||||
| public class S08EX02c { | ||||
|     public static void main(String[] args) { | ||||
|         String dep = "1234"; | ||||
|         System.out.println(dep + " -> " + stringsep(dep)); | ||||
|     } | ||||
|  | ||||
|     static String stringsep(String s){ | ||||
|         if (s == null) return null; | ||||
|         if (s.length() <= 1) return s; | ||||
|  | ||||
|         return "" + s.charAt(0) + ',' + stringsep(s.substring(1)); | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
							
								
								
									
										15
									
								
								src/Series/S08/S08EX02d.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/Series/S08/S08EX02d.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| package Series.S08; | ||||
|  | ||||
| public class S08EX02d { | ||||
|     public static void main(String[] args) { | ||||
|         char l = 'f'; | ||||
|         System.out.println(l + " -> " + letters(l)); | ||||
|     } | ||||
|  | ||||
|     static String letters(char l){ | ||||
|         if (l == 0) return null; | ||||
|         if (l == 'a') return String.valueOf(l); | ||||
|  | ||||
|         return letters((char)(l-1)) + l; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								src/Series/S08/serie8.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/Series/S08/serie8.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user