Nп/п : 14 из 100
 От   : Francesc Rocher                     2:5075/128        18 сен 23 06:04:21
 К    : Ben Bacarisse                                         18 сен 23 16:09:04
 Тема : Re: project euler 29
----------------------------------------------------------------------------------
                                                                                 
@MSGID:
<7a98a430-a01d-41e7-80fe-bc2e1e1592d3n@googlegroups.com> a07d6e4d
@REPLY: <87wmwnk9a9.fsf@bsb.me.uk> f325f193
@REPLYADDR Francesc Rocher
<francesc.rocher@gmail.com>
@REPLYTO 2:5075/128 Francesc Rocher
@CHRS: CP866 2
@RFC: 1 0
@RFC-References:
<beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com> <874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com> <87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com> <87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com>
<8734zcl4j0.fsf@bsb.me.uk> <87v8c8oyby.fsf@nightsong.com> <87wmwnk9a9.fsf@bsb.me.uk>
@RFC-Message-ID:
<7a98a430-a01d-41e7-80fe-bc2e1e1592d3n@googlegroups.com>
@TZUTC: -0700
@PID: G2/1.0
@TID: FIDOGATE-5.12-ge4e8b94
> > But Francesc`s program doesn`t use that method. It only suggests it in 
> > a comment. The program actually works by building a list, sorting it, 
> > and counting the groups.

> I only looked briefly and thought it used the factor method to decide if 
> the power is one that occurs earlier in the sequence. Two trivial 
> things, starting with Answer as the full NxN count and then decrementing 
> Answer made me think that was what it was doing. 

Exactly, that`s the point: to find if for a given base+exponent a**b there is an
equivalent x**y with  2 <= a < x <= 100  and  2 <= y <= 100, first a and b are
factored as a product of prime numbers. In case a has multiple times the same
 factor, e.g. 27 = 3*3*3 = 3**3, then the exponent 3 is used as a
new factor of the
exponent. Introducing this factor requires that the list of factors of b must be
 sorted to find a new base x, a < x. Otherwise you could find x
> 100 and consider
 that there is no such pair x and y within the limits. That`s the
only reason the list
of factors is sorted when a new one is introduced.

Example:
   27**100 = (3*3*3)**(2*2*5*5)
           = (3**3)**(2*2*5*5)
           = 3**(2*2*3*5*5)
           = 9**(2*3*5*5)
           = 81**(3*5*5)
           = 81**75

On the other hand, the algorithm first assumes that all possible combinations of
a**b are unique, and then subtracts 1 each time x and y are found for a and b.

 Implementing the equality operator for a**b = x**y is also an
alternative algorithm.
 Using it would require a loop for a in 2..99, b in 2..100, x in
a+1..100 and y in 2..100.
Is this correct? Or are there other constraints?

 Anyway, for big numbers, having the equality operator a**b = x**y
with the factoring
method is a good idea.

 Unfortunately, my Project Euler programs are prepared to be inserted
into the new Alice
 project, which is a (big) work in progress and cannot be compiled
easily (it requires
Alire, Project Euler for Alice and my sources, which depend on the Euler Tools).
If anyone is interested, for performance comparison or whatever reason, I can
provide a stand alone version.


BR,
-- Francesc Rocher
--- G2/1.0
 * Origin: usenet.network (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх