Hello everyone,
In School I was inspired to code a programm which calculates the number of sheep you can have in minecraft after a certain number of days.
Sheep grow up over the Course of a day and two adult sheep can have just one lamb. The sex of the sheep doesn’t matter, they’re male and female a once. They can’t mate again till their lamb has grown up.
Following you see a pic of my code (ignore the comments, I made them for me so they’re in german)
Please help me find my mistake.
Here I’ve got the whole code for you:
var Tage = prompt("Wie viele Tage willst du die Schafe vermehren? (du beginnst mit zwei Schafen)");
var anzahlSchafe = 2;
var Schafe = function(Tage)
{
for (var i = Tage ; i > 0; i = i-- );
{
var ungeradeGerade = anzahlSchafe % 2;
if ( ungeradeGerade == 0 );
{
var anzahlSchafe = +anzahlSchafe + +(+anzahlSchafe / 2 );
};
else
{
var anzahlSchafe = +anzahlSchafe + +((+anzahlSchafe - 1 ) / 2 );
};
};
return anzahlSchafe;
};
document.write(Schafe(Tage)