© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Search
Star
Feedback
Setup for Free
C
C#
•
3y ago
•
16 replies
moshimoshi
✅ Algorithm analysis
Can someone help me understand how we got this formula to calculate time efficiency from this code
?
sum = 0
loop i from 1 to n
loop j from 1 to i
sum = sum + 1
sum = 0
loop i from 1 to n
loop j from 1 to i
sum = sum + 1
this is the formula
: f
(n
)
= n2
/2
+ n
/2
, which is O
(n2
)
The formula goes like this
, 1
+ 2
+ 3
+ 4
+
.
.
.
+ N but i have no idea how to connect the dots
. Thanks
!
C#
Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Recent Announcements
Similar Threads
miniMax algorithm
C
C# / help
4y ago
Exception Signing Algorithm
C
C# / help
2y ago
simple algorithm question
C
C# / help
2y ago
✅ Specific Sorting Algorithm
C
C# / help
3y ago