Files
2025-07-29 10:37:06 +08:00

11 lines
388 B
Cython
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
def calculate(int n):
cdef int i
cdef long long result = 0
# cdef int result = 0 # 这个类型在数值比较大的时候会溢出,结果不正确。
# result = 0 # 这个不声明类型,使用 Python 的 intPython 的整数是任意精度的,不会溢出,但性能会比 C 类型低。
for i in range(n):
result += i
return result