The task of Problem 5 is to calculate triangular numbers. By playing with dots we can produce also square numbers like:
* * * * * * * * * * * * * * * * * * * * 1: * 4: * * 9: * * * 16: * * * *
or hexagonal numbers:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 1: * 6: * * 15: * * * 28: * * * *
 
According to those rules we can create polygonal numbers for all regular polygons.
 
Your task: given S and N calculate N-th S-gonal numbers P(S,N)
 
Examples:
see the test suite for more hints
I think the numbers in the description may be wrong. For hexagonal numbers, shouldn't the progression be [1,6,15,28]?
I believe that test suite number 6 is a little bit unfair, since the difficulty of this problem relies on creating the function that gives the n-th s-gonal number, and not making use of meshgrid or bsxfun.
Remove test case 6 please.. it makes no sense
Explain why. It makes a lot of sense to me, and it's a lot easier (and makes even more educational sense) with 2016b. Just learn the difference between * and .* and ask yourself you need 1st or 2nd.
1137 Solvers
558 Solvers
Project Euler: Problem 2, Sum of even Fibonacci
460 Solvers
Celsius to Fahrenheit converter
280 Solvers
178 Solvers