Computer Science, asked by rajalwsu, 4 months ago

Write a program to display all of the integers from 1 up to and including some integer entered by the user followed by a list of each number's prime factors. Number greater than 1 that only have a single prime factor will be marked as prime.

For Example, if the user enters 10 then the output of the program should be:

Enter maximum value to display: 10

1= 1
2= 2 (prime)
3= 3 (prime)
4= 2x2
5= 5 (prime)
6= 2x3
7= 7 (prime)
8= 2x2x2
9= 3x3
10= 5x2

Answers

Answered by pawankumardnn378
1

Answer:

the answer is 2*5

Explanation:

the answer is 2*5

Answered by Roop2005
1

Answer:

n = int(input("Enter a limit: "))

pf = []

def prime(a):

   c = 0

   for i in range(1, a + 1):

       if a % i == 0:

           c += 1

   if c == 2:

       return a

   else:

       return 1

for i in range(2, n + 1):

   if prime(i) == i:

       pf.append(i)

l = len(pf)

if n >= 1: print("1==1")

for i in range(2, n + 1):

   if prime(i) == i:

       print(i, "=", i, "(prime)")

   else:

       print(i, end=" = ")

       a = []

       var = i

       for k in range(0, l):

           while var % pf[k] == 0:

               a.append(pf[k])

               var /= pf[k]

       l1 = len(a)

       for y in range(0, l1 - 1):

           print(a[y], end=" x ")

       print(a[l1 - 1])

Explanation:

If you dont understand wp notify me

Similar questions