Tested this solution and the one with sum(range(1, num + 1)), so with argument of 1000, I had these results: range: 14.2409 sec formula: 0.1098 sec I know this is obvious, I shared it just for anybody who is curious
Quick Maffs!
Mate, this is the most intriguing and clever ways to solve this problem of summation. Hats off to you!
This comment is hidden because it contains spoiler information about the solution
Pure math is alsways in theory faster. Learned this algo from a friend of mine, will always remember it for sum of range problems starting at 0 or 1
very very clever
i like the unusual way
That's a good trick, i didn't know about that.
I'm not that good at math fam
perfection**
I feel so dumb lmao
"¹234" returns True because str.isdigit treats superscripts as digits. Instead str.isdecimal should be used.
best code with less execution time
This is great, thanks for this
Loading collection data...
Tested this solution and the one with sum(range(1, num + 1)), so with argument of 1000, I had these results:
range: 14.2409 sec
formula: 0.1098 sec
I know this is obvious, I shared it just for anybody who is curious
Quick Maffs!
Mate, this is the most intriguing and clever ways to solve this problem of summation. Hats off to you!
This comment is hidden because it contains spoiler information about the solution
Pure math is alsways in theory faster. Learned this algo from a friend of mine, will always remember it for sum of range problems starting at 0 or 1
very very clever
i like the unusual way
This comment is hidden because it contains spoiler information about the solution
That's a good trick, i didn't know about that.
I'm not that good at math fam
perfection**
I feel so dumb lmao
"¹234" returns True because str.isdigit treats superscripts as digits.
Instead str.isdecimal should be used.
best code with less execution time
This is great, thanks for this
Loading more items...