.text
.align 2
main:

addi $sp, $sp, -4
sw $ra, 0($sp)	
	
la $t0, n
lw $a0, 0($t0)	
jal fact

add $a0, $v0, 0
li $v0, 1
syscall

lw $ra, 0($sp)	
addi $sp, $sp, 4
	
jr $ra	
	
	

	
.text
.align 2
fact:	

addi $sp, $sp, -8
sw $ra, 0($sp)
sw $s0, 4($sp)
	
addi $v0, $0, 1	
addi $t0, $0, 1	
beq $a0, $t0, target

add $s0, $a0, $0
addi $a0, $a0, -1
jal fact
mul $v0, $s0, $v0	
	
target:	 
lw $ra, 0($sp)
lw $s0, 4($sp)
addi $sp, $sp, 8
jr $ra	


	
.data
.align 2
n: .word 3