安全问答

安全问答是一个知识全球问答,包含丰富的问答知识

首页 常规 游戏 娱乐 科技 程序员

计算100到1的阶乘之和c++

  • 日期: 2028-12-02
  • 标签: 教育

#include

using namespace std;

int factorial(int n) { if (n == 0 || n == 1) { return 1; } else { return n * factorial(n - 1); } }

int main() { int sum = 0; for (int i = 100; i >= 1; i--) { sum += factorial(i); } cout << "The sum of factorials from 100 to 1 is: " << sum << endl; return 0; }

计算100到1的阶乘之和c++

原文地址: https://www.cveoy.top/t/topic/igfz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录

  • 上一篇: php匹配一下字符串 bMyqg0NtgtXD5n7tNwUQt6-70KMojUwA72oU0e
  • 下一篇: 计算100的阶乘c++

© 2019 • 2025 - 安全问答 站长邮箱:wxgpt@qq.com    ICP备案/许可证号:豫ICP备2024104334号-2