This site requires JavaScript, please enable it in your browser!
Greenfoot back
aaronlee3388
aaronlee3388 wrote ...

2015/6/3

how do you solve this using a loop or "if" statements ?

aaronlee3388 aaronlee3388

2015/6/3

#
Problem Description Natalie is learning to count on her fingers. When her Daddy tells her a number n (1 ≤ n ≤ 10), she asks “What is n, Daddy?”, by which she means “How many fingers should I hold up on each hand so that the total is n?” To make matters simple, her Daddy gives her the correct finger representation according to the following rules: • the number may be represented on one or two hands; • if the number is represented on two hands, the larger number is given first. For example, if Natalie asks “What is 4, Daddy?”, her Dad may reply: • 4 is 4. • 4 is 3 and 1. • 4 is 2 and 2. Your job is to make sure that Natalie’s Daddy gives the correct number of answers. Input Specification The input will be a single integer in the range 1..10. Output Specification The output is the number of ways of producing that number on two hands, subject to the rules outlined above. Sample Input 4 Output for Sample Input 3
davmac davmac

2015/6/3

#
I believe this is a homework problem. You should show that you have thought about the problem, rather than asking us to solve it for you. As a hint: What should the output be for n = 1, n = 2, n = 3, n = 4 ... ? (You can figure these out by hand). Do you see a pattern?
aaronlee3388 aaronlee3388

2015/6/3

#
yeah... i wrote out the out puts 1 = 1 2,3 = 2 4,5= 3 6,7 = 4 8,9 = 5 10 = 6 but i dont know how to use a generic way to solve it(i'm a beginner). please help
danpost danpost

2015/6/3

#
Try developing formulas for odd numbers and even numbers separately.
aaronlee3388 aaronlee3388

2015/6/4

#
would recursion work better with this scenario?
danpost danpost

2015/6/4

#
aaronlee3388 wrote...
would recursion work better with this scenario?
Totally unnecessary.
aaronlee3388 aaronlee3388

2015/6/4

#
can you provide me with more information please, this assignment is due tomorrow and i really need help
danpost danpost

2015/6/4

#
Plot the points (n, f(n)) on a graph. Connect the even 'n' points and the odd 'n' points separately. Determine the equation of the resultant graphed functions.
aaronlee3388 aaronlee3388

2015/6/4

#
Thanks!
You need to login to post a reply.