Skip to content

Instantly share code, notes, and snippets.

@Lydon-01
Created November 18, 2017 04:55
Show Gist options
  • Save Lydon-01/f41f73878aca361fdf24f9e4097fb3fd to your computer and use it in GitHub Desktop.
Save Lydon-01/f41f73878aca361fdf24f9e4097fb3fd to your computer and use it in GitHub Desktop.
Years before savings reaches 1million
public int yearsTilOneMillion(double initialBalance) {
int year = 1;
double savings = initialBalance;
while (savings < 1000000){
savings = savings * 1.05;
year++;
}
return year;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment