Ethically, do I need to include as coauthor a person who provided basic knowledge to fill a gap in my research? Consider the following scenario.

I am researching on a problem in a domain and I don't know anything about the existence of Pythagoras theorem.

After so much time of my research I figured myself that if a fact like: 


  the square of a side which is opposite to the 90 degrees in a triangle is equal to the sum of squares of remaining sides


exists, then my research completes and I can publish a good paper. But I never encountered Pythagoras theorem during my search of literature.

If I came to know about its existence during a discussion with a colleague or any random person, then is there any ethical need to keep him as a co-author since I struggled a lot of time and didn't find by myself?
The International Council of Medical Journal Editors (ICMJE) has established four criteria for being considered an author. The person's contribution should fulfill all four criteria. If not, they need to be considered as a non-author contributor and their contribution acknowledged, such as in Acknowledgements section. You can read about the different criteria and designation here. To directly answer your question, the person would be a non-author contributor.