Question: Write cube(N) that works for all integers, negative (8 marks), positive (5 marks), and zero (2 marks). Write a program that implements this definition of

 Write cube(N) that works for all integers, negative (8 marks), positive

Write cube(N) that works for all integers, negative (8 marks), positive (5 marks), and zero (2 marks). Write a program that implements this definition of cube numbers (for positive integers): cube(1) - 1 cube (N) - cube (N-1) + 3* (square(N)) - 3*N + 1 Implement the square() method using this definition given in assignment 13 (also for positive integers): square(1) - 1 square(N) = square(N-1) + 2*N - 1 Note: The math-like definition of square(N) does not work for negative N because the recursive step asks for square(N-1), which for negative integers is a harder problem than the original. For example, square( -5 ) asks for square( -6). For a definition of square(N) that works for negative integers (only) do this: (N+1)2 - N2 + 2N + 1 N2 = (N+1)2 - 2N -1 Create a similar definition for cube(N) that works for negative integers. Write cube(N) that works for negative integers (only). Make a complete program similar to PyramidTester.java given in the lesson

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!