卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章16333本站已运行3317

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

程序说明

五维体数是帕斯卡三角形的任意一行中第五个数字,从左到右或从右到左开始,起始于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 4end{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.

Use the formula

$$left(begin{array}{c}n+3 4end{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("

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("

"); printf("Printing the Pentotope Numbers upto Nth Term"); printf("

Print Pentatope Numbers till the term: "); scanf("%d",&n1); printf("

"); printf("The Pentotope Numbers are:"); printf("

"); for (i = 1; i <= n1; i++){ nthterm1 = (i * (i + 1) * (i + 2) * (i + 3) / 24); printf("%dt", nthterm1); } getch(); return 0; }

输出

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

卓越飞翔博客
上一篇: 在C/C++中,有预增和后增两种操作
下一篇: 如何提高C++大数据开发中的数据处理速度?
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏