comp.lang.ada
 help / color / mirror / Atom feed
From: Wes Groleau <wwgrol@ftw.rsc.raytheon.com>
Subject: Re: Sums of cubes (was Re: histrionics)
Date: 1999/09/27
Date: 1999-09-27T00:00:00+00:00	[thread overview]
Message-ID: <37EF9F5E.ADB1D7D@ftw.rsc.raytheon.com> (raw)
In-Reply-To: 37EC14A2.2289AAEB@mitre.org

"Robert I. Eachus" wrote:
> 
> Wes Groleau wrote:
> >               when Constraint_Error =>
> >                 null;  -- If the sum gets a constraint error
> >                        -- and the number didn't, it's not a match.
> >                        -- In a block because we don't want an
> >                        -- error on 9,999 to prevent checking 10,000
> >                        -- (I think Robert missed this detail.)
> 
>    Nope, the sum of cubes of 999 is 3*729 = 2187, the sum of cubes for
> 9999 is
> 2916, etc.  If you were going for something like the tenth power it
> would be an issue.

Or if the package is instantiated with 0..1000 (for example).  Without
the handler for constraint_error, my version would stop at 99.
(I should have used 99 in the comment.)  Since Robert's version used
non-generic integers, it did not have that problem.  
(i.e., I apologize for my false accusation.)

Robert's version is undoubtedly more efficient, but mine is simpler.
However, if you're doing five digits or less, either version will take
longer to compile than to run.  Six digits runs in ten seconds
on a slow SPARC.  Seven digits is runs under 2.5 minutes.  So up to
seven digits, the optimizing analysis takes longer than a very
UNoptimized computation.

But Robert's fact about 9999:2916 made me think:

The largest possible sum-of-cubes for six digits is 6 * 9**3 = 4374
The smallest possible six-digit number is bigger than that.
So it's pointless to go beyond five digits.  Or is my math wrong?

Took less than a minute to show with a spreadsheet that

with power of      you can stop at
2                       3 digits
3                       5 digits
4                       5 digits
5                       6 digits
6                       7 digits
7                       8 digits
8                       9 digits
9                      10 digits




  reply	other threads:[~1999-09-27  0:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-09  0:00 histrionics G
1999-09-08  0:00 ` histrionics Preben Randhol
1999-09-09  0:00   ` histrionics G
1999-09-09  0:00     ` histrionics Nick Roberts
1999-09-09  0:00       ` histrionics Robert Dewar
1999-09-10  0:00         ` histrionics Vladimir Olensky
1999-09-10  0:00           ` histrionics Robert Dewar
1999-09-10  0:00             ` histrionics Ted Dennison
1999-09-11  0:00               ` histrionics Bob Collins
1999-09-12  0:00                 ` histrionics Vladimir Olensky
1999-09-13  0:00                 ` histrionics Ted Dennison
1999-09-11  0:00             ` histrionics Vladimir Olensky
1999-09-11  0:00               ` histrionics Robert Dewar
1999-09-11  0:00                 ` histrionics Vladimir Olensky
1999-09-13  0:00                   ` histrionics Robert Dewar
1999-09-11  0:00               ` histrionics Robert Dewar
1999-09-11  0:00                 ` histrionics Vladimir Olensky
1999-09-14  0:00                 ` histrionics Robert I. Eachus
     [not found]                   ` <7s2l7b$kmr$1@nnrp1.deja.com>
     [not found]                     ` <37E81661.6DCA23E4@mitre.org>
1999-09-22  0:00                       ` histrionics Ehud Lamm
     [not found]                       ` <7saju5$6h6$1@nnrp1.deja.com>
1999-09-22  0:00                         ` histrionics Robert I. Eachus
1999-09-22  0:00                       ` histrionics p.obry
1999-09-23  0:00                   ` histrionics Ehud Lamm
1999-09-23  0:00                     ` Sums of cubes (was Re: histrionics) Robert I. Eachus
1999-09-24  0:00                       ` Wes Groleau
1999-09-24  0:00                         ` Robert I. Eachus
1999-09-27  0:00                           ` Wes Groleau [this message]
1999-09-24  0:00                       ` Robert Dewar
1999-09-24  0:00                         ` Robert I. Eachus
1999-09-24  0:00                       ` Wes Groleau
1999-09-25  0:00                         ` Robert Dewar
1999-09-23  0:00                     ` histrionics Ehud Lamm
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox