+ 33
[ASSIGNMENT] LCM (X,Y) = W (lcm 4 least common multiple)
Your task is to find total number of possible ordered pairs (x,y) such that they satisfy condition : LCM(x,y) = W where x,y,W belongs to set of whole numbers Examples : For input : 3 //W=3 [(1,3),(3,3),(3,1)] => 3 possible ordered pairs such that LCM(x,y)=3 output : 3 input : 12 output : 15 👉ALREADY SUBMITTED AS AN ASSIGNMENT👈
26 Answers
+ 3
This is another algorithm, in it the bust is reduced to a minimum. He handles such numbers as 54000000000 and factorial from 22.
https://code.sololearn.com/c5crJIjCtv71/?ref=app
+ 27
https://code.sololearn.com/c8ihT2i5X0ZI/?ref=app
+ 15
u can make ur own post containing all the best ones & marking it best 😂😂😂😂
u might get xp too🤣🤣🤣
+ 14
nice suggestion @DT
//it does not give any xp
//looks like some1 made a cool code
+ 13
sure @Vaibhav
//U missed some possibilities like
(12,3),(12 ,4), (12,6), (6,12), (3,12), (4,12), (2,12), (12,2), (6,4), (4,6)etc
+ 13
//try 2 mine own challenge 😅
https://code.sololearn.com/cOhOt9cgecGJ/?ref=app
+ 12
@Kazi , "lowest common multiple of x & y " is lowest number which comes in table of both x & y
👉now LCM(1,1) = 1 //as 1 is the lowest no. comes in table of both 1,1
//so 1 not equals to 12 ... hence soln rejected
👉LCM(2,3)=6 //as 6 is the lowest number which comes in table of both 2&3
similarily ... f (1,2)=2 , f (1,3)=3 ,f (1,4)=4,f (1,6)=6
//since these are not equal to 12 .... these are not cases to be counted
//similarily , U can reject some more cases from the set of orders U given ... where f (x,y) is not coming out to be 12
//hope i explained well 😅
//assuming input is 12 & f (x,y) means LCM(x,y)
+ 11
no option to mark more than 1 answer as best 😅
//any idea???
+ 9
#Thanks Gaurav..
here's my solution.
https://code.sololearn.com/cSBIIOc3VpM7/?ref=app
+ 6
I want to point out that not all forms of access to SL enable the submission of an assignment. In this case, posts like this should be considered transitional until all platforms allow lesson submissions.
+ 6
why it's not?when I entered 12?
please explain...buddy.😊
[(1, 1), (1, 2), (1, 3), (1, 4), (1, 6), (1, 12), (2, 1), (2, 2), (2, 3), (2, 4), (2, 6), (2, 12), (3, 1), (3, 2), (3, 3), (3, 4), (3, 6), (3, 12), (4, 1), (4, 2), (4, 3), (4, 4), (4, 6), (4, 12), (6, 1), (6, 2), (6, 3), (6, 4), (6, 6), (6, 12), (12, 1), (12, 2), (12, 3), (12, 4), (12, 6), (12, 12)]
+ 5
uffff... brute force... suboptimal.. sometimes ugly... what else can I say about my solution... IT WORKS!!! 💃💥🎉 https://code.sololearn.com/cO5OW5Rn7A6x/#java
so now I'm finally free to look into other people's codes )))
+ 4
Now, what is the LCM part please
ETA:
Ok, middle school was a long time ago and I didn’t make the connection between the acronym and the Least Common Multiple concept. Wow that was a while back.
+ 4
I gave it a try::
https://code.sololearn.com/cs1I2ahoGpi0/?ref=app
+ 4
https://code.sololearn.com/cK92JOabhWDB/?ref=app
+ 2
use the assignment section and summit your challenge
+ 2
hey guys, I think lukArToDo has passed this challenge, any other....
+ 2
Optimized version
https://code.sololearn.com/c5V4jyPNHrQ0/?ref=app