您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2024/5/16 17:57:02发布20次查看
程序说明五维体数是帕斯卡三角形的任意一行中第五个数字,从左到右或从右到左开始,起始于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)$$
algorithmaccept the nth term from the user to find the pentotope numbers.
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("
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("%d\t", nthterm1); } getch(); return 0;}
输出
以上就是在c语言中编写一个程序,打印出n个五角数的序列的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product