ホームページ  >  記事  >  バックエンド開発  >  N 個の五角形の数値のシーケンスを出力するプログラムを C 言語で作成します。

N 個の五角形の数値のシーケンスを出力するプログラムを C 言語で作成します。

王林
王林転載
2023-08-25 14:25:11962ブラウズ

プログラムの説明

5 次元の数は、パスカルの三角形の任意の行の 5 番目の数であり、5 項の行 1 4 6 から始まり、左から右、または右から左に始まります。 4 1.

この種の最初の数は、

1, 5, 15, 35, 70, 126, 210, 330, 495, 715, 1001, 1365

です。ペンタトープ数は、規則的な離散幾何学パターンとして表すことができる図形数のクラスに属します。 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 番目を受け入れるペントトープ数を見つけるためのユーザーからの用語。

式を使用します

$$\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("</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;
}

出力

N 個の五角形の数値のシーケンスを出力するプログラムを C 言語で作成します。

以上がN 個の五角形の数値のシーケンスを出力するプログラムを C 言語で作成します。の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事はtutorialspoint.comで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。