id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > quiz2023_12_13_HL_eToTheX
prev  |  next  |  chance

Write a method that uses the 'n'-th degree Maclaurin expansion of e to the x, to approximate the value of e to the 'x' for the given 'x' and 'n' values. The Maclaurin expansion of e to the x is the sum of all the terms from k=0 to k='x' of (x^k)/(k!) where "!" is the factorial symbol. Remember that factorial is a form of repeated multiplication such that 4!=4*3*2*1=24 and 5!=5*4*3*2*1=120. You MAY want to write one or more helper methods (or not)! Part of the challenge of this problem is to do things efficiently enough so that you do not cause the test data to time out! THINK FIRST! Preconditions: 'x' and 'n' will be small enough so that overflow errors in the data type 'double' will NOT be an issue. The value of 'n' will be a number from 0 to 50 inclusive. As always, look at the test data! BIG HINT: You MUST consider the efficiency of your approach or you are likely to get timeout errors.


quiz2023_12_13_HL_eToTheX(14.0, 0) → 1.0
quiz2023_12_13_HL_eToTheX(-1, 50) → 0.36787944117144245
quiz2023_12_13_HL_eToTheX(-3, 50) → 0.049787068367863986

...Save, Compile, Run (ctrl-enter)

public double quiz2023_12_13_HL_eToTheX(double x, int n) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy