The program code for printing Pascal’s Triangle.
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				 The build was successful.
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	 The build was successful.
				
			This commit is contained in:
		
							
								
								
									
										25
									
								
								tests/pascal_triangle.aer
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								tests/pascal_triangle.aer
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| class Program { | ||||
|  | ||||
| 	private int fun(int $y) { | ||||
| 		int $result = 1; | ||||
| 		for(int $z = 1; $z <= $y; $z++) { | ||||
| 			$result *= $z; | ||||
| 		} | ||||
| 		return $result; | ||||
| 	} | ||||
|  | ||||
| 	void main() { | ||||
| 		int $z; | ||||
| 		int $y = 5; | ||||
| 		for(int $x = 0; $x < $y; $x++) { | ||||
| 			for($z = 0; $z <= ($y - $x - 2); $z++) { | ||||
| 				print(' '); | ||||
| 			} | ||||
| 			for($z = 0; $z <= $x; $z++) { | ||||
| 				print($this->fun($x) / ($this->fun($z) * $this->fun($x - $z)), ' '); | ||||
| 			} | ||||
| 			print("\n"); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										5
									
								
								tests/pascal_triangle.exp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tests/pascal_triangle.exp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
|     1  | ||||
|    1 1  | ||||
|   1 2 1  | ||||
|  1 3 3 1  | ||||
| 1 4 6 4 1  | ||||
		Reference in New Issue
	
	Block a user