总结
豆包 AI 助手文章总结
首页 > 后端开发 > C++ > 正文

在C语言中编写一个程序,打印出N个五角数的序列

王林
发布: 2023-08-25 14:25:11
转载
1179人浏览过

程序说明

五维体数是帕斯卡三角形的任意一行中第五个数字,从左到右或从右到左开始,起始于5项行1 4 6 4 1。

这种数字的前几个是

1, 5, 15, 35, 70, 126, 210, 330, 495, 715, 1001, 1365
登录后复制

Pentatope numbers belong in the class of figurate numbers, which can be represented as regular, discrete geometric patterns. The formula for the nth pentatopic number is

$$\left(\begin{array}{c}n+3\ 4\end{array}\right)=\left(\frac{n(n+1)+(n+2)+(n+3)}{24}\right)=\left(\frac{n^2}{4!}\right)$$

Algorithm

Accept the Nth Term from the User to find the Pentotope Numbers.

立即学习C语言免费学习笔记(深入)”;

Use the formula

$$\left(\begin{array}{c}n+3\ 4\end{array}\right)=\left(\frac{n(n+1)+(n+2)+(n+3)}{24}\right)=\left(\frac{n^2}{4!}\right)$$

Example

/* Program to print pentatope numbers upto Nth term */
#include<stdio.h>
int main() {
   int n, n1, nthterm, nthterm1, i;
   clrscr();
   printf("</p><p> Please enter the nth term to print Pentatope: ");
   scanf("%d",&n);
   nthterm = n * (n + 1) * (n + 2) * (n + 3) / 24;
   printf("The Pentotpe Number is: ");
   printf("%d", nthterm);
   printf("</p><p></p><p>");
   printf("Printing the Pentotope Numbers upto Nth Term");
   printf("</p><p> Print Pentatope Numbers till the term: ");
   scanf("%d",&n1);
   printf("</p><p></p><p>");
   printf("The Pentotope Numbers are:");
   printf("</p><p></p><p>");
   for (i = 1; i <= n1; i++){
      nthterm1 = (i * (i + 1) * (i + 2) * (i + 3) / 24);
      printf("%d\t", nthterm1);
   }
   getch();
   return 0;
}
登录后复制

输出

在C语言中编写一个程序,打印出N个五角数的序列

以上就是在C语言中编写一个程序,打印出N个五角数的序列的详细内容,更多请关注php中文网其它相关文章!

全能打印神器
全能打印神器

全能打印神器是一款非常好用的打印软件,可以在电脑、手机、平板电脑等设备上使用。支持无线打印和云打印,操作非常简单,使用起来也非常方便,有需要的小伙伴快来保存下载体验吧!

下载
相关标签:
来源:tutorialspoint网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
豆包 AI 助手文章总结
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号