Answer:
wdadawdawdawdawdawdawdawsdwfawf
Step-by-step explanation:
Program 4: But I haven’t taken Calculus yet! OK – we admit, this one might look nasty, but read on because it’s not that bad. One of the things that computing folks do A LOT (especially CS students) is analyze how long a program takes to run. In the first step, something might take 1 unit of CPU time. The second step might take 2, the third 3 and so on. Mathematically, that would be expressed by the "summation" operator as this: ∑???? ???? ????=1 This is may look complex, but all it’s saying is that i goes from 1 to n and you sum all those numbers together. So, if (n = 10), ∑???? ???? ????=1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55 Fortunately, this reduces to a simple formula. When summing numbers from 1-n, the sum is: (n+1)*n/2 Why? It’s all in how you "pair" the numbers together. In the example above, we could pair (1+10) =11, (2+9)=11, (3+8)=11 and so on. That is, we have n/2 "pairs" of (n+1). Your task is, without using a loop (which we haven’t covered yet), to write a program that asks the user for a number, then prints out the sum of 1 to that number. If you use a loop, you will receive no credit