Google+ Program to Find Prime Factors of a Number in C++ [How to] - CodieeHome
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”
__

How to Find Prime Factors [C++]

Goal:- Program for Finding Prime factors of a given number.

Method:-  There are many methods which you can implement but as this post is only for beginners so I will try to keep it simple. 

Basic Idea:-  If you are a beginner to coding or wants to become good coder the first step to work on your mindset.The way we approach the problem represent how good coder we are. So before you code anything try to understand the problem by dividing it into as many parts as you can. So let's start with the Prime Factors. 

Before We start writing a program which find prime factors of a number we must learn what is the prime factor or How we calculate them in math.

Prime Numbers- Numbers which are only divisible by 1 or itself. Like 5,2,3

Prime Factors-  Breaking down a Number into combination of Prime Numbers.



Example:- Here we will break down 24 into its Prime Factors-

  • 24 -- 2 X 12 
  • 24 -- 2 X 2 X 6 (2 is a prime number but 12 isn't )
  • 24 -- 2 X 2 X 2 X 3 (Similar to above 6 wasn't a prime number)
  • 24 --  2 X 2 X 2 X 3 (All numbers are the prime number.)






      Program:-

       

      Output:-

      Enter a number:24 The prime factors are: 2 2 2 3
      This program is requested by our subscriber. If you also want to request any project or program.Please send us a request via Contact us or our Facebook  page.

      If you want to share more information about topic discussed above or find anything incorrect Please do comments.  

      For more Programs Stay Connected..Like us on Facebook.
      Next
      This is the most recent post.
      Previous
      Older Post

      0 comments:

      Post a Comment

       
      Top