series_sum_yourlogin - % % ---- Input Section ----sum_value...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
function[sum_value,num_terms]=series_sum_yourlogin(user_val) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Programmer(s) and Purdue Email Address(es): % 1. % % Section #:ALL % % Assignment #: Homework 5 Problem 3 % % Academic Integrity Statement: % % I/We have not used source code obtained from % any other unauthorized source, either modified % or unmodified. Neither have I/we provided access % to my/our code to another. The project I/we am/are % submitting is my/our own original work. % % This function determines the number of terms in the series 2^k which are % required for the sum of the terms to exceed a specified value. % % INPUTS % user_val = the user specified value the sum should not exceed % % OUTPUTS % sum_value = sum of the series % num_terms = number of terms added to series before exceeding value. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the 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.

Page1 / 2

series_sum_yourlogin - % % ---- Input Section ----sum_value...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online