Problem 5. Triangle Numbers
Solution Stats
Problem Comments

24 Comments
i dint realize i was writing a code for sum of first n natural numbers instead of computing n*(n+1)/2
Man, this takes me back to algebra... Its more fun in MATLAB tho!
It's interesting to work with and building the confidence to solve problems....nice
Good one. Reminds me of those old school days..!!
All solutions with score 10 or 11 use the regexp cheat.
Jon or anybody!
Can you explain how the regexp cheat works?
How do you reduce the size of your code?
mucha fantasía en el titulo
what it means?
I really had to use my brain for this problem
Interesting!
sound simple but annoying
Funny and interesting problem!
good!
For clarity sake,
t = triangle (n)
We need to calculate t for a given n
It is pretty easy but tricky!
Why doesn't this work?
function t = triangle(n)
t=1
for i=[1:(n+1)]
t=t+i;
t
end
that was fun
Cool problem!
Interesting
cool
The formula makes this an easy math problem.
Good Question
+10 points
Solution Comments
Show commentsProblem Recent Solvers26565
Suggested Problems

Maximum running product for a string of numbers
2137 Solvers

Project Euler: Problem 2, Sum of even Fibonacci
2213 Solvers

Calculate the area of a triangle between three points
2784 Solvers

5147 Solvers

442 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!