added weekly exercises of isp-ws25

This commit is contained in:
2026-04-13 19:02:19 +02:00
parent c51e836ed9
commit 00fdd31a18
28 changed files with 1835 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
#include <stdio.h>
int lucas(int number);
int main(void)
{
int index_position = 0;
int lucas_number = 0;
printf("Enter index position: ");
scanf("%d", &index_position);
if(index_position < 0)
{
printf("Entered position must be a non-negative integer\n");
return 1;
}
lucas_number = lucas(index_position);
printf("lucas(%d) = %d\n", index_position, lucas_number);
return 0;
}
int lucas(int number)
{
int result = 0;
if(number == 0){return 2;}
if(number == 1){return 1;}
result = lucas(number - 1) + lucas(number - 2);
return result;
}