Computer Science, asked by AdiK1needy, 1 year ago

write a code in JavaScript to find all prime factors of a input number.

Answers

Answered by Naveenbadhshah
1
code of JavaScript. I hope it's help you please mark as a brainlist
Attachments:

AdiK1needy: what is the second last statement, is it alert()?
Naveenbadhshah: altert str
AdiK1needy: what does it do?
AdiK1needy: I am confused in this thing: suppose a number is divisible by a prime more than 1 time, but code the code block say to increment var int even if it is repeated more than 1 time??
AdiK1needy: could you please help me with this thing? thanks again for your help
AdiK1needy: ☺️☺️
Answered by Anonymous
1

Explanation:

Answer:

Explanation:

# Python3 code to find nth ugly number  

# This function divides a by greatest  

# divisible power of b  

def maxDivide( a, b ):  

while a % b == 0:  

 a = a / b  

return a  

# Function to check if a number  

# is ugly or not  

def isUgly( no ):  

no = maxDivide(no, 2)  

no = maxDivide(no, 3)  

no = maxDivide(no, 5)  

return 1 if no == 1 else 0

# Function to get the nth ugly number  

def getNthUglyNo( n ):  

i = 1

count = 1 # ugly number count  

# Check for all integers untill  

# ugly count becomes n  

while n > count:  

 i += 1

 if isUgly(i):  

  count += 1

return i  

Similar questions