Q:

Test a series of numbers to ensure they fit the sequence 1,2,3...n

I am trying to find a slightly more elegant solution to find if a sequence of numbers is in order.   This is for a web form, and I am giving the user a chance to number items and that will set up the order.   I know the maximum number of items, and it should always start at one.   
Right now (I know it is not correct) I test to make sure all the numbers are different and add up to what it should (e.g. for three items I test it adds to 6).   Does anyone have a better/more accurate (since it is possible to go break mine) solution?   I am using php, but what I really want is logic so your example could be in pseudo-code or any relatively easy to read language. 

A:

Just sort the user-input numbers, and see if they match an index that you increment by 1.  
nMax = 10
sortedUserArray = Sort(UserArray)

For i = 1 To nMax
    If Not sortedUserArray(i) = i Then
        ' Input not valid.  
        ' Throw an error or something.  
    End If
Next i

For the Sort part, there exists a variety of sorting algorithms: Quicksort, Straight insertion, Heapsort, etc.  Just pick one that fits your needs and do a search to find a ready-made procedure on the web.  Your language of choice may even have some built-in sorting algorithms, so you might not even need to look that far. 