Saint Louis University |
Computer Science 1300/5001
|
Computer Science Department |
Please make sure you adhere to the policies on academic integrity.
Write a program that allows the user to enter a nonnegative integerĀ \(k\) and returns the sum of the first \(k\) perfect squares, $$\sum_1^k{k^2}.$$ For example, if \(k=4\) the sum should be \(1^2 + 2^2 + 3^2 + 4^2 = 1 + 4 + 9 + 16 = 30\). A sample execution might appear as
Enter k: 4
30
Ask the user for a word and then output the following pattern.
Enter word: example
e
ex
exa
exam
examp
exampl
example