Skip to content

Commit

Permalink
10 | 5 | sharafat
Browse files Browse the repository at this point in the history
  • Loading branch information
SharafatKarim committed Aug 4, 2023
1 parent 9ac3843 commit c71b8d1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
30 changes: 30 additions & 0 deletions solutions/sharafat/10/4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// n order polinoial
// Generated with AI

#include <stdio.h>
#include <math.h>

int factorial(int n)
{
if (n == 1)
return 1;
else
return n * factorial(n - 1);
}

float evaluate(int x, int n, int i)
{
if (n >= 11)
return 0;
else if (i % 2 == 0)
return -pow(x, n) / factorial(n) + evaluate(x, n + 2, i+1);
else
return pow(x, n) / factorial(n) + evaluate(x, n + 2, i+1);
}

int main()
{
int n;
scanf("%d", &n);
printf("%f\n", evaluate(n, 1, 1));
}
22 changes: 22 additions & 0 deletions solutions/sharafat/10/5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>

void fibonacci(int n)
{
int i, a = 0, b = 1, c;
for (i = 0; i < n; i++)
{
printf("%d ", a);
c = a + b;
a = b;
b = c;
}
}

int main()
{
int n;
printf("Enter number to generate fibonacci series: ");
scanf("%d", &n);
fibonacci(n);
printf("\n");
}

0 comments on commit c71b8d1

Please sign in to comment.