This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programming Diversions and the fly likes 1-1+1-1.. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Other » Programming Diversions
Reply Bookmark "1-1+1-1.." Watch "1-1+1-1.." New topic
Author

1-1+1-1..

Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1854
Each of a1,a2,a3..aN are either 1 or -1.
The expression S = a1*a2*a3*a4+a2*a3*a4*a5+....+aN*a1*a2*a3 = 0
(* means multiplication and a1*a2 means value of a1 multiplied by value of a2)
Prove that 4 divides N.
I have taken this from Problem Solving Strategies


MH
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1854
If sign of every a(i) is changed,nothing changes .If sign of two a(i)s are same and other two are of different,nothing changes.If sign of one or three a(i) are different then S changes by +-4.If all four a(i) are of same sign,then S changes by +-8.That means S is changing by +-4 or +-8.
S=0mod(4).But S = n hence 4 divides n.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: 1-1+1-1..
 
Similar Threads
puzzling % operator
arrays
List in HashMap
Errors in Devkas SCJP Exam question 23 of 72 (in assessment)
Garbage Collector doubt (Examlab Diagnostic Test) Q4