#!/usr/local/bin/python3.6
def ff(n):
for i1 in range(1, n + 1):
for i2 in range(1, i1 + 1):
print('%s*%s=%s' % (i1, i2, i2 * i1), end=' ')
print()
ff(9)
#!/usr/local/bin/python3.6
def jiec(n):
if n == 1:
return 1
else:
return n * jiec(n-1)
print(jiec(5))
#!/usr/local/bin/python3.6
import sys
def fbnq(n):
if n < 1:
return -1
if n == 1 or n == 2:
return 1
else:
return fbnq(n-1) + fbnq(n-2)
i = fbnq(int(sys.argv[1]))
if i != -1:
print(i)
#!/usr/local/bin/python3.6
def hnt(n, x, y, z):
if n == 1:
print(x, '--->', z) ##如果只有一层,那么直接从x拿到z
else:
hnt(n-1, x, z, y) ##n-1 ,将x拿到y上面,用z来过度
print(x, '--->', z) ##把最后一层拿到z
hnt(n-1, y, x, z) ##此时都在y上面,将y以x为过度拿到z
i = 3
hnt(i, 'X', 'Y', 'Z')