คำอธิบายโปรแกรม
ตัวเลขเพนทาโทปคือตัวเลขในเซลล์ที่ห้าของแถวใดๆ ของสามเหลี่ยมปาสกาลที่เริ่มต้นด้วยแถวที่ 5 เทอม 1 4 6 4 1 จากซ้ายไปขวาหรือจากขวาไปซ้าย
ตัวเลขสองสามตัวแรกของประเภทนี้คือ
1, 5, 15, 35, 70, 126, 210, 330, 495, 715, 1001, 1365
หมายเลข Pentatope อยู่ในคลาสของตัวเลขที่เป็นรูปเป็นร่าง ซึ่งสามารถแสดงเป็นรูปแบบทางเรขาคณิตที่ไม่ต่อเนื่องได้ตามปกติ สูตรสำหรับเลขเพนทาโทปิกที่ n คือ
$$\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)$$
อัลกอริทึม
ยอมรับเงื่อนไขที่ N จากผู้ใช้เพื่อค้นหาหมายเลข Pentotope
ใช้สูตร
$$\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)$$
ตัวอย่าง
/* Program to print pentatope numbers upto Nth term */
#include<stdio.h>
int main() {
int n, n1, nthterm, nthterm1, i;
clrscr();
printf("\n 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("\n\n");
printf("Printing the Pentotope Numbers upto Nth Term");
printf("\n Print Pentatope Numbers till the term: ");
scanf("%d",&n1);
printf("\n\n");
printf("The Pentotope Numbers are:");
printf("\n\n");
for (i = 1; i <= n1; i++){
nthterm1 = (i * (i + 1) * (i + 2) * (i + 3) / 24);
printf("%d\t", nthterm1);
}
getch();
return 0;
} ผลลัพธ์
