I'm having trouble with the last bit of code, where the years are calculated and printed. The loop seems to run once fine. If I put in something like 12 to start and want to get 13 it will give me the result of 1 year. But anymore than that and it seems to break. It won't print anything, and the program keeps running until I manually end it. I'm at my wit's end.
#include <cs50.h>
#include <stdio.h>
#include <math.h>
int main(void)
{
// TODO: Prompt for start size
int start;
do
{
start = get_int("How many llamas do you have?\n");
}
while (start < 9);
// TODO: Prompt for end size
int end;
do
{
end = get_int("How many llamas do you want?\n");
}
while (end < start);
// TODO: Calculate number of years until we reach threshold
int years = 0;
int herd = start;
while (herd < end)
{
herd = trunc (start + (start / 3) - (start /4));
years++;
}
printf("That will take %i", years); printf(" years!\n");
}