N=sum of primes between smallest and largest prime factor of N (inclusive).
Find all possible values for the composite number N below 300.
We consider p(i) and p(j) where the composite number is
p(i)p(j) = sum [ {n=i->j) p(n) ]
call these composites "duos"
or
p(i)p(j)p(k) = sum [ {n=i->k} p(n) ]
call the composites "trios"
Going for composites made of 4 prime almost immediately exceeds
300 so we don't do it.
rabbit-3:~ lord$ hh
duos
p(i) p(j) product sum
2 5 10 10
3 13 39 39
5 31 155 155
trios
none
rabbit-3:~ lord$ more hh.f
program pp
implicit none
integer cnt,i,j,k,l,n,p(48),duo,trio,sum
open(2,file='primes1.txt',status='old')
do i=1,6
j=8*i-7
read(2,*)(p(l),l=j,j+7)
enddo
print*,'duos'
do 1 i=1,44
do j=i+1,45
sum=0
duo=p(i)*p(j)
if(duo.gt.300)go to 1
do n=i,j
sum=sum+p(n)
enddo
if(sum.eq.duo)print*,p(i),p(j),duo,sum
enddo
1 enddo
print*,'trios'
cnt=0
do 2 i=1,43
do j=i+1,44
if(p(i)*p(j).gt.300) go to 2
do k=j+1,45
sum=0
trio=p(i)*p(j)*p(k)
if(trio.gt.300)go to 3
do n=i,k
sum=sum+p(n)
enddo
if(trio.eq.sum)then
cnt=cnt+1
print*,p(i),p(j),p(k),trio,sum
endif
enddo
3 enddo
2 enddo
if(cnt.eq.0)print*,' none '
end
Edited on October 19, 2018, 8:07 am