1,105,332 Community Members

Practice Problem: Unit Sum

Member Avatar
firstPerson
Industrious Poster
4,052 posts since Dec 2008
Reputation Points: 761 [?]
Q&As Helped to Solve: 634 [?]
Skill Endorsements: 24 [?]
 
0
 

I know we haven't been doing much of these C++ Community problems so I though I'd write one up to get it started once again.

Problem Statement: For some integer v,w,x,y,z find all solution to the following equation

   1   1   1   1   1
   - + - + - + - + - = 1
   v   w   x   y   z

For example one solution is v = w = x = y = z = 5, find the rest. If there are none the prove it with your code or some algebra. Happy coding fellas.

Member Avatar
VernonDozier
Posting Expert
5,632 posts since Jan 2008
Reputation Points: 2,218 [?]
Q&As Helped to Solve: 768 [?]
Skill Endorsements: 26 [?]
Featured
 
2
 

There's nothing specifying that the numbers have to be positive. In that case, there are an infinite number of solutions, or since we're talking computer, "billyuns and billyuns" of them as our favorite astronomer used to say. v = w = x = 3. y and z and arithmetic inverses of each other (1, -1), (2, -2), (3, -3), etc so their reciprocals add to zero and they drop out. That's four billion right there. There are 5 choose 2 = 10 ways of picking which pair of variables are arithmetic inverses, so make it 40 billion and I'm just getting warmed up. Shall we change the problem to requiring the integers to all be positive?

Member Avatar
mike_2000_17
21st Century Viking
4,081 posts since Jul 2010
Reputation Points: 2,253 [?]
Q&As Helped to Solve: 799 [?]
Skill Endorsements: 73 [?]
Moderator
Featured
Sponsor
 
2
 

I guess we also have to specify that the formula is not computed with integer arithmetic. Otherwise, for any integer greater than 1, the division would yield 0, and thus, there would be "billyuns and billyuns" of possibilities too (2^160 for 32bit unsigned integers). ;)

Member Avatar
firstPerson
Industrious Poster
4,052 posts since Dec 2008
Reputation Points: 761 [?]
Q&As Helped to Solve: 634 [?]
Skill Endorsements: 24 [?]
 
0
 

Omg nitpickers haha. Sorry should have been more precice.

  • For all positive number v,w,x,y,z
  • 1/a is not an integer division
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article