#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;
}
