Alan Gauld
2015-10-02 23:42:51 UTC
"A pentagonal number is defined as
n(3n - 1)/2 for n = 1,2 etc.
It's asking you to write a function that returns then(3n - 1)/2 for n = 1,2 etc.
result of the equation.
Here is a simpler example
Write a function with the following header that
returns a squared number:
def getSquare(n):
And the solution looks like:
def getSquare(n):
return n*n
You need something similar for your pentagonal numbers.
Write a test program that uses this function to display the
first 100 pentagonal numbers with 10 numbers on each line."
I assume you know how to use for loops?first 100 pentagonal numbers with 10 numbers on each line."
This is just a nested for loop. The outer for the 10 lines
and the inner for the 10 values per line
If you need more help then reply explaining which bits
you are confused about and we can break it down further.
Note: as policy we do not provide solutions to homeworks
but we will give suggestions/hints etc.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor