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

 

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

In mathematics, the double factorial (or semifactorial) of a number n, denoted by n‼, is the product of all the integers from 1 up to n that have the same parity (odd or even) as n. This is NOT the same thing as iterating the factorial function twice like this: (n!)!. For example, the double factorial of 9, written as 9!!, is the product: 1*3*5*7*9 which is 945. The double factorial of 6 (6!!) is 2*4*6 which equals 48. Write a RECURSIVE method that returns the double factorial of 'num'. Note that 'num' is passed in as an integer, but the function returns a double because these values can get very large very quickly. Note that many of the value of 'num' in the test data will result in the answer being returned in scientific notation, and may only be approximate answers. That is OK. You don't have to give exact answers if they exceed the precision capabilities of double.


quiz2022_02_24_HL_doubleFactorial(1) → 1.0
quiz2022_02_24_HL_doubleFactorial(2) → 2.0
quiz2022_02_24_HL_doubleFactorial(3) → 3.0

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

public double quiz2022_02_24_HL_doubleFactorial(int num) { }

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: 450

Copyright Nick Parlante 2017 - privacy