## DEV Community is a community of 615,790 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

# Day 4 of 100DaysOfCode: Code to Calculate HCF Of Two Numbers

Today is my 4rth day of coding. Today I gave my time for file handling. I have been so much confused. I am not clear about some concept of it yet. Today I also did some code on function, dictionary in some mathematical problem. I gave some time of mine to the Freecodecamp and Coursera too.
Below is the code of mine for today, which I wrote to find the HCF of two numbers. For this code, I used a function to do the job. At first, I asked the user to input two numbers integer type. Then I find the maximum and minimum of these two numbers. I created an empty list name of CF to store a common factor. I started looping from 1 to the minimum number. Because the possibility of HCF will be from 1 to a minimum among these two numbers. Below is my code.

``````def higher_common_factor():
n1 = int(input('enter the number'))
n2 = int(input('enter the number'))
m1 = min(n1,n2)
m2 = max(n1,n2)
cf = []
for n in range(1,m1+1):
if m1 % n == 0 and m2 % n ==0:
cf.append(n)
print(f"{cf}")
higher_common_factor()
``````

## Discussion (4) 