All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Product of odd primes with distinct digits (Posted on 2021-07-23) Difficulty: 2 of 5
(1): Consider the set of the smallest 6 odd primes: {3,5,7,11,13,17}.
What is the largest multiple of this product which has distinct digits ?

(2) What is the maximum number of digits a square-free integer (whether even or odd) can have if its digits are all distinct?

(3) What is the largest odd square-free integer with distinct digits having exactly n prime factors for n = 1,2,3,4,5? You can extend this to larger numbers of factors if you wish.

Note: a square-free integer is one whose prime factorization has exactly one factor for each prime that appears in it.

See The Solution Submitted by Larry    
Rating: 5.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 5 |
Part 1

The product is p= 4849845.

and  63047985 = 13 * p

found by

p=prod(primes(19))/2
t=p;
while t<9876543210
   t=t+p;
   good=true;
   n=char(string(t));
   for i=2:length(n)
      f=strfind(n,n(i)) ;
      if f(1)<i
         good=false;
         break
      end
   end
   if good 
      disp([t t/p]) 
   end
end

Part 2:


clearvars, clc
allDigs='9876543210'; didPrime=false;
largen=0; largeEven=0;
for digs=9:9
   combs=nchoosek(allDigs,digs);
   for i=1:length(combs)
      p=perms(combs(i,:));
      for j = 1:length(p)
         n=str2num(p(j,:)); 
         f=factor(n);
         if length(f)==1  
           if didPrime==false 
            disp([n f]) 
            didPrime=true;
           end 
         else
           if f(1)~=2  
             if n>largen  
              if length(unique(f))==length(f)
               disp([f n]) 
               largen=n;
              end
             end 
           else
               if n>largeEven
                  if length(unique(f))==length(f)
                   disp([f n]) 
                   largeEven=n;
                  end
               end
           end
         end
      end
   end
end

finds


        2029      486769   987654301
           2           5    98765431   987654310
           
meaning

product of primes 2029 and 486769 is 987654301

Including evens, the product 2 * 5 * 98765431 = 987654310

Part 3:

clearvars, clc
allDigs='9876543210'; didPrime=false;
largen=zeros(1,9); largeEven=zeros(1,9);
for digs=9:-1:8
   combs=nchoosek(allDigs,digs);
   for i=1:length(combs)
      p=perms(combs(i,:));
      for j = 1:length(p)
         n=str2num(p(j,:)); 
         f=factor(n);
         lf=length(f);
         if lf==1  
           if n>largen(1)
              largen(1)=n; 
           end
         else
           if f(1)~=2  
            if lf<10   
             if n>largen(lf) 
              if length(unique(f))==length(f)
               disp([f n]) 
               largen(lf)=n;
              end
             end 
            end
           else
             if lf<10  
               if n>largeEven(lf)
                  if length(unique(f))==length(f)
                   disp([f n]) 
                   largeEven(lf)=n;
                  end
               end
             end
           end
         end
      end
   end
end
disp(largen)
disp(largeEven)

largest odd with n prime factors:
n
1  987654103    prime
2  987654301    2029      486769
3  987654201     3    23    14313829
4  987652403    41    53    61  7451
5  987652043     7    17    29   137  2089
6  987630215     5    11    13    17   193   421
7  987462105     3     5     7    23    37    43   257
8  820614795     3     5     7    11    13    31    41    43
9  none found with either 9 or 8 digits
   The product of the first 9 odd primes is already a 10-digit number: 3234846615.
 
While evens were not asked for, here are even solutions also:
 
1  no 9-digit even numbers with only one prime factor (all have 2)
2  987653042     2   493826521
3  987654310     2   5    98765431
4  987654302     2   347  661  2153
5  987654230     2   5    73   419  3229
6  987650314     2   7    23    97   103   307
7  987534210     2   3     5    13    23    89  1237
8  987452610     2   3     5    19    29    31    41    47
9  857146290     2   3     5     7    11    13    17    23    73

It took 2209 seconds = 36 min 49 sec to run.

Edited on July 23, 2021, 2:18 pm
  Posted by Charlie on 2021-07-23 14:16:24

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (23)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information