![]() Topic awaiting preservation: Need help with a math trick question (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: you tell me |
![]() Hi guys, I've come face to face with a math problem and can't seem to get over it for the last couple of days. It goes like this: |
Paranoid (IV) Inmate From: Florida |
![]() You crossposter, you. |
Maniac (V) Mad Scientist with Finglongers From: Germany |
![]() the way you describe it, I can't follow how this machine is supposed to work. Does it add digits or numbers? |
Maniac (V) Inmate From: San Antonio |
![]() I think he means numbers, although digits would work too, you'd just be limited by what base you're working in (base 10 gives you a max of N=9 {1,2,...,9}, base 16 gives you a max of N=15 {1,2,...,F}). code: int[] numbers = {2, 3, 5, 2, 1, 4}; int N = numbers.Count -1; // 5 (Count includes the duplicate) int sum = 0; for(int i=0; i<=numbers.Count; i++) { sum += numbers[i]; sum -= i; }
|
Maniac (V) Mad Scientist with Finglongers From: Germany |
![]() ok, if you have the n+1 numbers it's trivial |
Maniac (V) Inmate From: San Antonio |
![]() quote:
quote:
|
Bipolar (III) Inmate From: Cranleigh, Surrey, England |
![]() Hmm, the problem does seem a tad odd. I would say, up to rearrangement, you have a sum of the form 1+...+N+x, and you want x. code: greatest possible sum for N = 1+...+N+N < 1+...+(N+1)+1 = least possible sum for N+1
code: javascript:numberToTest=13;for(n=1,m=numberToTest;(m-=n)>n++;){};alert(m?m:'Impossible Sum')
|