← 返回 meta 的题目列表Calculate Sum and Product
类型:online_judge
meta
Implement a function that takes a list of integers and returns an array where the first element is the sum of all integers, and the second element is the product of all integers.
Parameters:
A list of integers nums (1 <= len(nums) <= 1000, -1000 <= nums[i] <= 1000)
Return:
An array, the first element is the sum of the integers, and the second is the product.
Examples:
Input: [1, 2, 3, 4]
Output: [10, 24]
Input: [5, -2, 3]
Output: [6, -30]
Example
Input
1, 2, 3, 4