Please answer using pseudocode. Aka answers in english. Please dont use any spec
ID: 3770956 • Letter: P
Question
Please answer using pseudocode. Aka answers in english. Please dont use any specific code language as I am in an introductory logic class. 1. Write a program that will read in a positive integer and print all of the factors of the number. Note: Factors are numbers that divide evenly into the number. To simulate modulus, we use the % symbol. 2. Write a program that reads in two positive integers and prints out the least common multiple (LCM). The least common multiple is the number that both positive integers divide into evenly.
Explanation / Answer
1) Pseudocode for reading a number and print its factors.
Here I have given comments for your understanding i.e. // comment
Input variable num //Get a variable from the user(keyboard)
For i = 1 to num //Run the program from i=1 and incrementing i by 1 and it reaches the value num
If num is divisible by i Then
Print "i is a factor"
End If
Next i
2) Pseudocode for LCM
Here I have given comments for your understanding i.e. // comment
Get a and b // where a and b are 2 numbers taken from the user
Set Ma to a // Ma is the multiple of a
Set Mb to b // Mb is the multiple of b
While Ma<>Mb //while loop is similar to for loop above(condition is that Ma not equal Mb)
{ if (Ma > Mb) then // finding which multiple is smaller
Set Mb to Mb + b // we add to the smaller multiple the input value
Else
Set Ma to Ma + a
End if
}
Print "the LCM of the numbers is" + Ma