Cho giá trị n. Nhiệm vụ: tính số Icosahedral tâm thứ n.
Số Icosahedral tâm là gì?
Số Icosahedral tâm là số tâm (centered number) biểu diễn icosahedron (đa diện 20 mặt).
Dãy số đầu tiên: 1, 13, 55, 147, 309, 561, 923...
Công thức:
$$C(n) = (2n+1) \times \frac{5n^2 + 5n + 3}{3}$$
Ví dụ
Input – n = 20
Output – Centered Icosahedral Number: 28741
Input – n = 12
Output – Centered Icosahedral Number: 6525
Ví dụ code
#include <iostream>
using namespace std;
long long centeredIcosahedral(int n) {
return (2LL * n + 1) * (5LL * n * n + 5LL * n + 3) / 3;
}
int main() {
int num = 20;
cout << "Centered Icosahedral Number: " << centeredIcosahedral(num) << endl;
return 0;
}
Kết quả
Centered Icosahedral Number: 28741
Giải thích: Icosahedron có 20 mặt tam giác. Số centered icosahedral liên quan đến cấu trúc lớp vỏ của hình học này. Công thức suy ra từ hình học rời rạc.