-
-
Save Lydon-01/f41f73878aca361fdf24f9e4097fb3fd to your computer and use it in GitHub Desktop.
Years before savings reaches 1million
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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