Python was / is / will be my supreme assistant and best friend in the journey of analytic-thinking …
Analytical thinking means that the abstract separation of a whole into its constituent parts to study the parts and their relation. Except for its lexical meaning I believe in that it means problem-solving ability in the software world. However, in the first instance, we must accept that it is not easy to think in this way. And it does not drop out of the sky. In my opinion, the easiest and shortest way to gain this ability is to deal with problems without giving up.
On the contrary of high school, I was very far from natural sciences and when I saw a problem/task at the beginning of my BootCamp, I was feeling nauseated. I came through this by dealing with all problems/task which I have seen yet. During the course you deal with already a lot of assignments but if you say yourself that you want to be here to stay these can’t be sufficient. And when you can not come to the end of the task, if you give up easily, you are already the losers’ club.
“A function that includes two numbers and returns the smallest multiple of these numbers”
The above problem was the most challenging problem which I dealt with during the introduction of the course. When you are not acquainted with the rules, firstly you should google. If you do not understand how to do, you only waste your time by trying to constitute an algorithm. The second common mistake, which I have frequently done, trying to develop an algorithm without pseudo code. I have experienced that although I have dealt with almost one-day time without any solution when I start with pseudo code before the algorithm, I have finished the same task in one hour.
I want to come to the solution. The easiest solution is to solve the problem with the largest common divisor. If you divide tlcd of the given numbers to the multiplying of two given numbers, you get the smallest multiple of these numbers. You can see from here how to find tlcd.
But if we don’t know the tlcd, what will we do? In order to find the least common multiple, firstly we must query whether the divider is a prime number.
I have created a function that returns whether the divider is a prime number in order to use it in the main function.
In the main function, you need an empty list in order to append the true values. In order to set the algorithm, you need a counter so that you can divide both numbers to the counter. If the counter is a prime number and divides both numbers without rest you can set your algorithm with a nested condition. After adding the dividers into the empty list, you can find the solution by multiplying the numbers each other. To multiply the numbers in the list, you need a variable with “1” value as an integer.
You can reach from here the codes.