Question
(Python) The triangular numbers is the number sequence 0, 1, 3, 6, 10, 15, 21, 28, The n:th triangular number is defined as the sum
(Python) The triangular numbers is the number sequence 0, 1, 3, 6, 10, 15, 21, 28, The n:th triangular number is defined as the sum of the numbers from 0 to n, inclusive, that is, 0 + 1 + + n. Note that the sequence starts from zero: The zeroth triangular number is zero, and the first triangular number is 1. There is also closed-form formula for the n:th triangular number: T(n) = n (n + 1) / 2. Your task is to write a function triangular(n) that computes and returns the n:th triangular number for any non-negative integer value n. The function must take one argument (that is, have one parameter), which is the value of n, and it must return an integer value (a value of type int).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started