package com.test.day01; // public class TestParam { public void f1(int n){ n =0; } public static void main(String[] args) { TestParam testParam = new TestParam(); int n = 9; testParam.f1(n); System.out.println(n); } } 思考:上面的代码运行结果输出的是0还是9 答案是9 因为…
阶乘的递归实现,代码如下: def factorial(n): if n==1: return 1 else: return n*factorial(n-1) number = int(input("请输入一个正整数:")) result = factorial(number) print("%d 的阶乘是 %d" %(number,result)) 阶乘的迭代实现,代码如下: def factorial(n): result = n; for i in range…