Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    What exactly is the aim of "fastest" here? Is something like int n = sqrt((double) (2*k)); n*(n+1)/2 == k not fast enough for your purposes? Commented May 26, 2010 at 13:20
  • 2
    Testing this quickly is, one way or another, basically equivalent to testing whether an integer is a square, as others have pointed out. Here's a pretty extensive question devoted to that topic: stackoverflow.com/questions/295579/… Commented May 26, 2010 at 13:26
  • Is this part of a larger problem you're trying to solve? If so, perhaps you'd like to explain that instead? Commented May 26, 2010 at 13:39
  • @Bart: Yes, I need a fast check whether a network topology is every-to-every or not. Commented May 26, 2010 at 13:54