Added code to cleanup the variables at the end of the script

This commit is contained in:
2018-09-26 11:17:37 -04:00
parent b63ca10669
commit 2468bd4f80
5 changed files with 24 additions and 15 deletions

View File

@@ -3,7 +3,6 @@
%What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
%Create your variables
value = 0; %The value that is evenly divisible
nums = [1:20];
factors = [1]; %The factors that are already in the number
list = []; %For a temperary list of the factors of the current number
@@ -33,13 +32,12 @@ while(counter <= size(nums)(2))
++counter;
end
prod(factors)
%Cleanup your variables
clear counter;
clear factorCnt;
clear listCnt;
clear list;
clear nums;
clear ans; %Appears whenever you use increment
value = prod(factors);
value
clear factors;