浙江省高校计算机等级考试二级Python 程序设计题14——奇数乘积值|2023备考

笔记整理自B站UPWLB工作生活两不误的个人空间-WLB工作生活两不误个人主页-哔哩哔哩视频教程​​​​​​Python 程序设计题14_哔哩哔哩_bilibili

程序设计题14

Python代码

代码一

n = int(input())

s = 1

# 第一种
for i in range(1, n + 1):
    if i % 2 == 1:
        s *= i

print(s)
        

代码二

n = int(input())

s = 1

# 第二种
for i in range(1, n + 1, 2):
        s *= i
print(s)
        

输入样例

10

输出样例

945

猜你喜欢

转载自blog.csdn.net/Raider1/article/details/129967836
今日推荐