mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			626 B
		
	
	
	
		
			Solidity
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			626 B
		
	
	
	
		
			Solidity
		
	
	
	
	
	
| contract C {
 | |
|     function f(uint256 a) public returns (uint256 b) {
 | |
|         assembly {
 | |
|             function fac(n) -> nf {
 | |
|                 switch n
 | |
|                     case 0 {
 | |
|                         nf := 1
 | |
|                     }
 | |
|                     case 1 {
 | |
|                         nf := 1
 | |
|                     }
 | |
|                     default {
 | |
|                         nf := mul(n, fac(sub(n, 1)))
 | |
|                     }
 | |
|             }
 | |
|             b := fac(a)
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| // ====
 | |
| // compileViaYul: also
 | |
| // ----
 | |
| // f(uint256): 0 -> 1
 | |
| // f(uint256): 1 -> 1
 | |
| // f(uint256): 2 -> 2
 | |
| // f(uint256): 3 -> 6
 | |
| // f(uint256): 4 -> 24
 |