Question: Java Python bgoldner@northseattle.edu > double_sum prev next chance Write a function that is passed in a positive integer, n, and sum up all the digits

Java Python bgoldner@northseattle.edu > double_sum prev next chance Write a function that is passed in a positive integer, n, and sum up all the digits from 1 to n, doubling the even numbers. In other words, calculate and return the following sum. if n is odd: 1 + (2 * 2) + 3+ (4 * 2) + ... + ((n - 1) * 2) + n if n is even: 1 + (2 * 2) + 3+ (4 * 2) + ... + (n - 1) + (n* 2) double_sum(5) 21 double_sum(10) double_sum(1) 1 85 Bad code Don't print, compute and return ar Go ...Save, Compile, Run (ctrl-enter) def double_sum (n)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
