Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [m,a] = IRA(s,r)
- if isempty (s) s = 100; end %Spent hours on this, doesn't work
- if isempty (r) r = 5; end %Despite coming straight out of lecture slides
- % m is variable for months
- % a is variable for total amount
- % s is variable for savings per month
- % r is variable for interest rate
- m = 0;
- a = s * (1 + r/1200);
- while(m < 600 && a < 1000000)
- if a < 1000000
- a = s + a * (1 + r/1200);
- m = m + 1;
- elseif a >= 1000000
- m = m + 1;
- a = s + a * (1 + r/1200);
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement