这种数字的前几个是
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个五角数的序列的详细内容。
