about | help | code help+videos | done | prefs |
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) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 450
Copyright Nick Parlante 2017 - privacy