Task 1 (For and While -loop)
A) Write a program that uses a For-loop to sum the N first odd numbers greater than 30, i.e. the sum:
S = 31 + 33 + 35 +. . . + (31 + 2 · (N − 1)), where N> 0 is a positive integer and the last number in the sum is (31 + 2 · (N − 1)).
B) Write a program that uses a while loop to find the greatest value for N so that the sum (S) calculated by the program in 1a) does not exceed 1000.
C) Write a program that examines if there is a N that the sum calculated in 1a) is exactly 5301. If there is such N, the program should display the message “There is a such N” on the screen, and if there is no , the function should display the message “There is no such N”.
Last Completed Projects
topic title | academic level | Writer | delivered |
---|