This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: % % ---- Input Section ----sum_value = 0; % initialize series sum num_terms = 0; % initialize number of terms in series n % ---- Calculation Section ----if user_val <=0 % Checks that the user supplied value is positive sum_value = 'Specified value not positive'; num_terms = '0 terms summed'; else while sum_value <= user_val % Checks if current series sum is less than or equal to user specified value sum_value = sum_value + 2^num_terms; % Adds current term to series summation num_terms = num_terms + 1; % Increases the number of terms added to series by 1 end end e % >>[sum_value,num_terms]=series_sum_yourlogin(0) % sum_value = Specified value not positive % num_terms = 0 terms summed % % [sum_value,num_terms]=series_sum_yourlogin(25) % sum_value = 31 % num_terms = 5 % % [sum_value,num_terms]=series_sum_yourlogin(2000) % sum_value = 2047 % num_terms = 11...
View Full Document
This note was uploaded on 05/02/2011 for the course ENGR 132 taught by Professor Kutson during the Spring '11 term at Purdue University-West Lafayette.
- Spring '11