аватар question@mail.ru · 01.01.1970 03:00

Lay out the number into simple factors

How to put the number into the multipliers in Python so that their work is equal to this number.

  Number =  Int  ( input  ())   for  i  in   range  ( 1 , number+ 1 ):   if  (number%I ==  0 ):   print  (i)     

when entering the number (for example) 63. The output tus out:

   1    3    7    9    21    63      
  #!/usr/bin/env python3  n =  int  ( input  ( "" integer: "" )) factors = [] d =  2    when  d * d & lt; = n:   if  n %  0 : : : : : : : :  Factors.ppend (d)  n // = d  else :  d +=  1    if  n & gt;  1 :  factors.ppend (n)   else :   break    print  ( '{} = {}' .  format  (n, factors))     

at the output will be: 7 = [63, 3, 21, 3, 7]


and I need to get: I need to get: I need to get it: 63 = 3 * 3 * 7

аватар answer@mail.ru · 01.01.1970 03:00

This task is called

one of the implementations (taken C):

   de   Primfeacs  ( n ):  i =  2   primafac = []   when> i * i & lt; = n:   While  n % i ==  0 :  primafac.append (i)  n/n/i i +  1    if  n  n & gt;  1 :  primface.ppend (n)   retu  primface                                      

Latest

Similar