我想编写一个程序,打印出所有小于或等于 100000 的加泰罗尼亚数字。
这些由cn=1
和cn1 = ((4n+2)/n+2)*cn
(下一个值)给出。当我尝试它时,我收到以下错误。
我的代码是:
cn,cn1 = 1,2
n = 1
while cn1<100000:
cn1 = ((4(n+2)/(n+2)))*cn
print(cn1)
我的输出错误:
runfile('C:/Users/Admin/Desktop/cpy/ex_cat_numbe.py', wdir='C:/Users/Admin/Desktop/cpy') Traceback(最近一次通话最后):
文件“”,第 1 行,在 runfile('C:/Users/Admin/Desktop/cpy/ex_cat_numbe.py', wdir='C:/Users/Admin/Desktop/cpy')
文件“C:\Users\Admin\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py”,第 710 行,运行文件 execfile(文件名,命名空间)
文件“C:\Users\Admin\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py”,第 101 行,在 execfile exec(compile(f.read(), filename, 'exec') 中,命名空间)
文件“C:/Users/Admin/Desktop/cpy/ex_cat_numbe.py”,第 11 行,cn1 = ((4(n+2)/(n+2)))*cn
TypeError:“int”对象不可调用