mirror of
				https://github.com/onyx-and-iris/grokking-algorithms.git
				synced 2025-11-03 22:11:45 +00:00 
			
		
		
		
	add recursion
This commit is contained in:
		
							parent
							
								
									5b6a20dedf
								
							
						
					
					
						commit
						3a138acf93
					
				
							
								
								
									
										7
									
								
								chapter3/recursion.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								chapter3/recursion.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					def factorial(x):
 | 
				
			||||||
 | 
					    if x == 1:  # This is the base case
 | 
				
			||||||
 | 
					        return 1
 | 
				
			||||||
 | 
					    return x * factorial(x - 1)  # This is the recursive case
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					print(factorial(4))
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user