Python Forum
[Learning] 3 hours for one simple exercise
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Learning] 3 hours for one simple exercise
#4
There are some ambiguity (what does mean separated by four) but sum of every forth integer in range n should be simply:

>>> n = 100
>>> sum(i ** 2 for i in range(1, n+1, 4))
80825
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: [Learning] 3 hours for one simple exercise - by perfringo - Aug-25-2019, 10:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Plz help Ive tried for hours and cant do these three problems VB4 1 2,003 Mar-17-2018, 04:59 AM
Last Post: micseydel
  Simple exercise - how to write in python tomtom55 6 5,028 Sep-28-2017, 07:18 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020