Question

Find the smallest positive integer that has precisely n distinct prime divisors. 'Distinct prime divisor'Example: the...

Find the smallest positive integer that has precisely n distinct prime divisors. 'Distinct prime divisor'Example: the prime factorization of 8 is 2 * 2 * 2, so it has one distinct prime divisor. Another: the prime factorization of 12 is 2 * 2 * 3, so it has two distinct prime divisors. A third: 30 = 2 * 3 * 5, which gives it three distinct prime divisors. (n = 24 ⇒ 23768741896345550770650537601358310. From this you conclude that you cannot iterate through successive positive integers until you find the one you want. Use Python.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Checking for each and every integer , factorizing them and verifying them if they have n distinct prime divisors is very time consuming.The optimized is to avoid this approach and follow the below logic

The logic here is to find the n prime numbers and multiply them.

The smallest positive integer that has precisely n distinct prime divisors will hold the following properties :

1 . It will not have any repeated divisor (No single divisor repeats twice)

2 . It is formed by prime numbers multiplied in the ascending order

EX : smallest positive integer that has precisely 3 distinct prime divisors would be

30 = 2 * 3 * 5 where 2 ,3 , 5 are the first 3 prime numbers

6 = 2*3 , 6 is the smallest positive integer that has 2 distinct prime divisors

How Did I find Prime Numbers ?

I have used wilson's theorem to find the prime numbers

According to wilson theorem , if p is prime number then ((p-1)!+1)%p must be equal to 0

ex : 5 is prime

(5-1)!+1 = 4!+1

= 24 + 1

= 25

25%5 = 0

hence 5 is prime.

CODE :

#Calculate the given n no. of primes
def primes(n) :
prime = []
k=2
f = 1
while n>0 :
f = f * (k - 1)
if ((f + 1) % k == 0):
prime.append(k)
n = n-1
k = k+1
return prime

#Take the input
n = input("Enter the n value\n")
#Get n primes
p = primes(int(n))
ans = 1
#Multiply all primes until n
for i in p:
ans = ans * i
print("Smallest +ve integer that has precisely",n," distinct prime divisors :")
print(ans)

Spyder (Python 3.7) Eile Edit Searh So un Debug Consales Projects Tools View Help Vereble explorer roject explorer mppy X webrawlenpy X prima.pyX NameType Size 1 # -*. coding: utf-8-* int 1 30 3 Created on Tue May 21 00:9:03 2019 Bauthor: Rogue int 1 6#Calculate the given n no. of primes 7 def prines(n) 8 prine list 3 12, 3. 5 1 f 1 11 ile ne: 12 if((f t 1) % k-6): prime.append(k) n = n-1 Verieble explarer Fils aspicrar Help 14 Pytron consolc 16 17 return prine 18 19#Tale the input 20input("Cniter the n valuetn") 21 #Get n primes p pritn)) Enter the n value mallest ve integer that has precisely 4 distinct prine divisars 210 23 ans-1 24#Multiply all primes until n 5for i in p: In L10]: runtile'C:Users/Rague/Desktap/prine.py,wdir-'C:/Users/Rague Desktop) 26 2/ print( "Snallest we integer that has precisely",n," distinct prine divisors ") 28 print(ans) Enter the n valur 24. Snallest ave integer that has preciscly 24 distinct prine divisors 23768741896345558770650537601358310 In [11]: runileC/Users/Rogue/Desktop/prine, py,wdir-'C:/Users/Rogue Desktop') Enter the n valuc Smallestve integer that has precisely 3 distinct prine divisors 38 In [12]: Python cornele History og Permissicns: RW End-af-lines: CRLF Enpdin: UIF-B Line:28 Column: 11 Memory: 62% 1222 AM O Typc here to searc 5/21/20159

Enter the n value 4 Smallest tve integer that has precisely 4 distinct prime divisors: 210 In [10] runfile('C:/Users/Rogue/Desktop/prime.py', wdir-'C:/Users/Rogue Desktop") Enter the n value 244 Smallest +ve integer that has precisely 24 distinct prime divisors 23768741896345550770650537601358310 In [11]: runfile('C:/Users/Rogue/Desktop/prime.py', wdir-'C:/Users/Rogue/ Desktop') Enter the n value Smallest +ve integer that has precisely 3 distinct prime divisors 30 In [121:

Add a comment
Know the answer?
Add Answer to:
Find the smallest positive integer that has precisely n distinct prime divisors. 'Distinct prime divisor'Example: the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • IN PYHTON CODE Question #3 Produce a function prime_factors.dict that has one integer variable n that...

    IN PYHTON CODE Question #3 Produce a function prime_factors.dict that has one integer variable n that is assumed to be greater than 1. The function will return a dictionary with keys the integers from 2 to n, inclusive, and with values the set of prime factors of each key. So, the command prime_factors.dict (8) will return the dictionary 2 123,3: 3),4 2),5 (53,6 2,3),7:7),8 {2)) Note that even though the prime number 2 appears twice in the prime fac- torization...

  • The prime factorization of a positive integer n is p^3. Which of the following is true?...

    The prime factorization of a positive integer n is p^3. Which of the following is true? Explain and show your answers. I. n cannot be even II. n has only one positive prime factor. III, n has exactly three distinct factors.

  • A positive integer greater than 1 is said to be prime if it has no divisors...

    A positive integer greater than 1 is said to be prime if it has no divisors other than 1 and itself. A positive integer greater than 1 is composite if it is not prime. Write a program that defines two functions is_prime() and list_primes(). is_prime() will determine if a number is prime. list_primes() will list all the prime numbers below itself other than 1. For example, the first five prime numbers are: 2, 3, 5, 7 and 11." THE PROGRAM...

  • Question 3 (a) Write down the prime factorization of 10!. (b) Find the number of positive...

    Question 3 (a) Write down the prime factorization of 10!. (b) Find the number of positive integers n such that n|10! and gcd(n, 27.34.7) = 27.3.7. Justify your answer. Question 4 Let m, n E N. Prove that ged(m2, n2) = (gcd(m, n))2. Question 5 Let p and q be consecutive odd primes with p < q. Prove that (p + q) has at least three prime divisors (not necessarily distinct).

  • A prime number is a positive integer whose positive integer divisors are 1 and the number....

    A prime number is a positive integer whose positive integer divisors are 1 and the number. E.g. 17 is a prime number -23 is a not prime number 28 is not a prime number -45 is not a prime number The only even prime number is 2 Write a boolean function, isPrime that return true if its integer parameter is a prime and false if its integer parameter is not a prime number. A simple prime number algorithm is if...

  • Need help programing this in C. rinteivsors Print the proper divisors of an integer value The...

    Need help programing this in C. rinteivsors Print the proper divisors of an integer value The program should read a single integer input value, which you can assume will be positive. It should then print a single line of output with all of the proper divisors of the input value in order from least to greatest. A proper divisor d of an integer n is an integer that evenly divides n: i.e., nld is an integer For example, if the...

  • DEFINITION: For a positive integer n, τ(n) is the number of positive divisors of n and...

    DEFINITION: For a positive integer n, τ(n) is the number of positive divisors of n and σ(n) is the sum of those divisors. 4. The goal of this problem is to prove the inequality in part (b), that o(1)+(2)+...+on) < nº for each positive integer n. The first part is a stepping-stone for that. (a) (10 points.) Fix positive integers n and k with 1 <ksn. (i) For which integers i with 1 <i<n is k a term in the...

  • A perfect number is a positive integer that equals the sum of all of its divisors...

    A perfect number is a positive integer that equals the sum of all of its divisors (including the divisor 1 but excluding the number itself). For example 6, 28 and 496 are perfect numbers because 6=1+2+3 28 1 + 2 + 4 + 7 + 14 496 1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248 Write a program to read a positive integer value, N, and find the smallest perfect number...

  • Prime numbers are the building blocks of all integers greater than 1. Any integer n >...

    Prime numbers are the building blocks of all integers greater than 1. Any integer n > 1 can be written as a unique product of primes i.e. n = p1 × p2 × ... × pm. Here, pi are primes such that p1 ≤ p2 ≤ ... ≤ pm. Take, for example, the number 18. It can be written as 18 = 2 × 3 × 3. 1. Write a Python function prime divisors(n) which accept an integer n and...

  • Let n be a positive integer. Show that nº + 4n +5 has no prime divisor...

    Let n be a positive integer. Show that nº + 4n +5 has no prime divisor p with p 3 mod 4.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT