Skip to content

Commit d09d412

Browse files
committed
Add the Factorial and Power Functions Snippets in C
1 parent 7ba0f0d commit d09d412

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

public/data/c.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,42 @@
1818
"author": "0xHouss"
1919
}
2020
]
21+
},
22+
{
23+
"categoryName": "Mathematical Functions",
24+
"snippets": [
25+
{
26+
"title": "Factorial Function",
27+
"description": "Calculates the factorial of a number.",
28+
"code": [
29+
"int factorial(int x) {",
30+
" int y = 1;",
31+
"",
32+
" for (int i = 2; i <= x; i++)",
33+
" y *= i;",
34+
"",
35+
" return y;",
36+
"}"
37+
],
38+
"tags": ["c", "math", "factorial", "utility"],
39+
"author": "0xHouss"
40+
},
41+
{
42+
"title": "Power Function",
43+
"description": "Calculates the power of a number.",
44+
"code": [
45+
"int power(int x, int n) {",
46+
" int y = 1;",
47+
"",
48+
" for (int i = 0; i < n; i++)",
49+
" y *= x;",
50+
"",
51+
" return y;",
52+
"}"
53+
],
54+
"tags": ["c", "math", "power", "utility"],
55+
"author": "0xHouss"
56+
}
57+
]
2158
}
2259
]

0 commit comments

Comments
 (0)