酷代码 AI
菜单
服务商

Python 实现输入整数求和并判断总和是否为质数

以下是使用Python实现的代码: ```python # 读取整数的个数 n = int(input()) # 读取n个整数并转换为整数列表 numbers = list(map(int, input().split())) # 计算这些整数的总和 total = sum(numbers) # 判断总和是否为质数 if total < 2: result = "not prime" else: for i in range(2, int(total0.5) + 1): if total % i == 0: result = "not prime" break else: result = "prime" # 输出结果 print(result) ``` ######[AI问答 | 150点数解答 | 2025-11-08 20:26:18]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]