Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Off-by-one in Sigma #82

Open
Dalton-Gray opened this issue Jan 3, 2021 · 1 comment
Open

Off-by-one in Sigma #82

Dalton-Gray opened this issue Jan 3, 2021 · 1 comment

Comments

@Dalton-Gray
Copy link

sum([k for k in range(100)])

output: 4950

The reference said output: 5050
Which would be

sum([i for i in range(101)])
@tobiaszwingmann
Copy link

The second example of sigma is also wrong. The result should be 10200. Better define a custom function instead of using range like so:

def my_range(i):
  return([k+1 for k in range(i)])

and then call

sum([2*k + 1 for k in my_range(100)])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants