4 Replies - 2759 Views - Last Post: 14 March 2011 - 12:21 PM Rate Topic: -----

#1 cuddledumpling   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-March 11

Pascal's Triangle HW Help?

Posted 13 March 2011 - 05:23 PM

The instruction:

(a) Write a function choose fac(n,k) that computes

(n)
(k)

according to De nition (1), i.e., using n!
Hint: First de ne a function fact(n) that takes an integer n and returns n! as the result of the function.
You can use the code from class, e.g., the one that computes n! recursively (n! = n  (n 1)! for integers
n  1, and n! = 1 for n = 0), or the one that works iteratively (i.e., using n! = 1  2  : : :  n).
(B) Now write a function choose rec(n,k) that computes

(n)
(k)

according to De nition (2), i.e., recursively.

I don't quite understand recursion but I managed to do the program. How do I make it so that the program prints out in a triangle format?

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Pascal's Triangle HW Help?

#2 atraub   User is offline

  • Pythoneer
  • member icon

Reputation: 837
  • View blog
  • Posts: 2,271
  • Joined: 23-December 08

Re: Pascal's Triangle HW Help?

Posted 14 March 2011 - 06:05 AM

Could you post your code?
Was This Post Helpful? 0
  • +
  • -

#3 RoseWyvern   User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 17
  • Joined: 29-December 09

Re: Pascal's Triangle HW Help?

Posted 14 March 2011 - 11:30 AM

Here's a hint: the python center command.
http://docs.python.o...ary/string.html

If you need more specific help, post some code.

There are a few ways you can do it, so try to think about it in pseudo code.
Was This Post Helpful? -2
  • +
  • -

#4 Simown   User is offline

  • Blue Sprat
  • member icon

Reputation: 323
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: Pascal's Triangle HW Help?

Posted 14 March 2011 - 12:16 PM

That may well come in useful but a whole page of documentation isn't going to help much as they have not posted any code - we don't know what the problem is. Not really a good hint, is it?

Wait until they post some code before giving "hints".
Was This Post Helpful? 1
  • +
  • -

#5 atraub   User is offline

  • Pythoneer
  • member icon

Reputation: 837
  • View blog
  • Posts: 2,271
  • Joined: 23-December 08

Re: Pascal's Triangle HW Help?

Posted 14 March 2011 - 12:21 PM

Yeah, I'm with Simown. There's no reason for you to be an ass under the guise of trying pretending to help.

This post has been edited by atraub: 14 March 2011 - 12:26 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1