A triangular number is any number from the series of numbers (1, 3, 6, 10, 15,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A triangular number is any number from the series of numbers (1, 3, 6, 10, 15, etc.) obtained by continued summation of the natural numbers 1, 2, 3, 4, 5, etc Implement a function next triangular number (num) that takes an integer and determines the smallest triangular number that is equal to or larger than the given number. The function must: • take one argument: a positive integer, num return trig num, where trig.num is the smallest triangular number that is greater than or equal to num use a while-loop Example: calling next.triangular number (25) returns 28 as the triangular number 21 (1+2+3+4+5+6 = 21) is smaller than 25, and so the next triangular number 28 (1+ 2+3+4+ 5+6+7 = 28), which is bigger than 25, is the next triangular number in the series. A triangular number is any number from the series of numbers (1, 3, 6, 10, 15, etc.) obtained by continued summation of the natural numbers 1, 2, 3, 4, 5, etc Implement a function next triangular number (num) that takes an integer and determines the smallest triangular number that is equal to or larger than the given number. The function must: • take one argument: a positive integer, num return trig num, where trig.num is the smallest triangular number that is greater than or equal to num use a while-loop Example: calling next.triangular number (25) returns 28 as the triangular number 21 (1+2+3+4+5+6 = 21) is smaller than 25, and so the next triangular number 28 (1+ 2+3+4+ 5+6+7 = 28), which is bigger than 25, is the next triangular number in the series.
Expert Answer:
Answer rating: 100% (QA)
Codesnap Coding def trignumnumfunction here i1initilize it with i 0 su... View the full answer
Related Book For
Elementary Statistics A Step By Step Approach
ISBN: 978-1259755330
10th edition
Authors: Allan G. Bluman
Posted Date:
Students also viewed these mathematics questions
-
Write a function called is_even (n) that takes an integer as an argument and returns True if the argument is an even number and False if it is odd. Add your own tests to the test suite.
-
Write a short Java method that takes an integer n and returns the sum of all the odd positive integers less than or equal to n.
-
Write a short Java method that takes an integer n and returns the sum of all positive integers less than or equal to n.
-
Scott and Associates, Inc., is an accounting firm that has three new clients. Project leaders will be assigned to the three clients. Based on the different backgrounds and experiences of the leaders,...
-
Distinguish between a theory and a hypothesis.
-
Which statement is true for voltaic cells? a) Electrons flow from the anode to the cathode. b) Electrons flow from the more negatively charged electrode to the more positively charged electrode. c)...
-
Estimate the maximum mass flow rate of air that can be passed by the duct shown in Fig. P11.61 for \(\mu=4 \times 10^{-7} \mathrm{lb}\). \(\mathrm{s} / \mathrm{ft}^{2}\). Figure P11.61 Po 100 psia T...
-
Ethanol is produced commercially by the hydration of ethylene: C2H4 (g) + H2O (v) C2H5OH (V) some of the product is converted to diethyl ether in the undesired side reaction 2 C2H5OH (v) = (C2H5)2O...
-
On December 8, 1985, Gillian Stewart, her husband Keith Stewart, her brother Stuart Pettie, and his wife Shelley Pettie went to the Stage West, a dinner theatre in Edmonton for an evening of dinner...
-
Sandra?s Purse Boutique has the following transactions related to its top-selling Gucci purse for the month of October. Required: 1. Calculate ending inventory and cost of goods sold at October 31,...
-
Standard accounting practices typically prioritize historical cost over market value for several reasons: Objectivity : Historical cost is relatively objective and verifiable. It is based on actual...
-
By exploring the website coast.noaa.gov/hurricanes, identify the most severe hurricane that has occurred within 100 km of Chetumal, Mexico since 2000. How close did its eye come to Chetumal? Estimate...
-
4. Suppose that firm 1 and firm 2 each produce the same product and face a market demand curve given by Q=110-P. Both firms have a constant unit (marginal) cost of production c = c2 = 20. Firms...
-
A company pays for a purchase with a credit card. What is the effect of this purchase on the accounts?
-
April decided to deposit $6,000 into a CD that offers her an APR of 4.3 percent with quarterly compounding for 4 years. How much money will she have in this CD when it matures in 4 years? ( Round to...
-
Which if the following describes a way in which the Sortino Ratio differs from the Sharpe Ratio? The Sortino ratio incorporates kurtosis (fat tails) and the Sharpe Ratio does not The Sortino Ratio it...
-
Estimate the amount of work performed on a 1200 kg car as it accelerates at 1.2 m/s2 over a 150 meter distance. How fast will the car be moving at the end if it started from rest?
-
Complete the equations for the following equilibria and calculate Keq where the Keq expression includes [HO]. Be sure to enter Keq in proper scientific notation. (a) ammonia (acting as a base) reacts...
-
If 3 digits are selected at random with replacement, find the probability of getting at least one odd number. Would you consider this event likely or unlikely? Why?
-
Four cards are drawn from a desk without replacement. Find these probabilities. a. All cards are jacks. b. All cards are black cards. c. All cards are hearts.
-
Transportation officials reported that 8.25 out of every 1000 airline passengers lost luggage during their travels last year. If we randomly select 400 airline passengers, what is the probability...
-
A political pollster approaches people on the street and asks them to describe their political affiliation. Twenty-eight people describe themselves as Democrats, 25 as Republicans, 8 people provide a...
-
Listed below are a number of hypothetical research hypotheses. For each hypothesis, identify the independent and dependent variable. a. Male drivers are more likely to exhibit road rage behaviors...
-
Listed below are a number of research questions and hypotheses from actual published articles. For each hypothesis, identify the independent and dependent variable. a. The use of color in a Yellow...
Study smarter with the SolutionInn App