+ 5
Here is a Challenge [answer with a code] (01)
Anne and Bob were counting. Anne was counting slowly up to 2017. Everytime Anne would say a number Bob would add it to a running total. But everytime the number was a perfect square Bob would be so excited that he would add it twice. What is the total Bob gets to. P.S. The first one to answer gets the XP.
13 Answers
+ 13
Here's mine:
https://code.sololearn.com/cFjO319vE1Oc/?ref=app
+ 14
Better late than never :)
https://code.sololearn.com/cZGNsrEvVXqK/?ref=app
+ 7
@Kuba Siekierzyński
I got this ^^
https://code.sololearn.com/cwEgOLjEIW40/?ref=app
+ 6
https://code.sololearn.com/cZpAkjeEK0Og/?ref=app
Just a bit too late :(. Still posting it anyway.
+ 5
@Ulisses Cruz
N * (N + 1) / 2
is the same as 1 + 2 + 3 + ... + N - 2 + N - 1 + N
It gets the sum way faster than just iterating and adding.
Then I just iterate over the square numbers and add that again so that they are added twice.
+ 5
Anybody got this in Ruby? Or... ;)
+ 5
@Dennis 👏👏👏
+ 1
Waw. I'm glad I posted this challenge. I learned a lot with you guys.
EDITED
Thas a new method I want to remembre @Dennis.
0
Good method for testing perfect square @Kuba Siekierzyñski.
0
@Dennis can you explain your algorithm, please.
0
new challenge:
https://www.sololearn.com/discuss/435761/?ref=app
0
another challenge:
https://www.sololearn.com/discuss/435877/?ref=app
0
https://code.sololearn.com/can1HMtoKeSI/?ref=app