C Practical and Assignment Programs-Prime Factorization

preview_player
Показать описание
C Practical and Assignment Programs-Prime Factorization
It is the most common question asked in aptitude and interview.
In this video we are going to write a program to find the prime factors of given number. This program will print all the prime factors of the give number. But in this video we will also see how to organize code for better readability and re usability. Now this program is written in C programming language but will work in C++.Fell free to provide you suggestion.

We The Computer Guys
Shreyas Zagade
Aakash Thakur
Ananya Jain
Рекомендации по теме
Комментарии
Автор

can i put the prime factorization function inside the main function so that I dont have to put FindPrimeFactorization(n)

isaacblue
Автор

any way of doing this without having to put the primefactorization in the int main () function?

isaacblue
Автор

Visited on your blog but there's not showing any content

surajmahato
Автор

How to print the factors in descending order?
I tried this:
i=num;
and in the while loop, decremented the counter value i. Example: for 60, results are 30 2

namandeepkaur
Автор

why we should do { n=n/i } after printf.

vijayboda
Автор

Why don't you use the for loop?
//My version
for (ull i=2; i<=number and i*i<=number; ++i)
{

// integer division
while (number%i == 0)
{

cout<<i<<" ";

number /= i; // number = 28/2 = 14; n = number * 2**1
}

}

if (number != 1) // n=6, i=3, number = 3
{

cout<<number;
}

andytheodorko
Автор

Bro, can you tell us the code for SUM OF UNIQUE NUMBERS IN AN ARRAY
Ex:11, 12, 13, 12, 11, 11, 12
Sum:13
Thanks in advance

vangetinikhil
Автор

this is wrong, i tried to input 720, and there is 4 on the result, 4 is not prime factor

jos
Автор

Bro, how can I print like this:
1  2   3   4
5           8
9 10 11 12

will be grateful....

mehedirafi
Автор

write a program to display first x prime numbers in reverse order displaying 10 numbers in row.Only the alternate prime number should be displayed and considered.I want this answer, this type of questions asked in interview as a system test
how to do it easily!
  

ramyas
Автор

I don't see why your inner while loop is necessary... Here is my solution:
int N = 66;
int D = 2;
while(N!=1)
if(N%D)
D++;
else {
printf("%i ", D);
N = N/D;
}

Havc
Автор

would u print 
2
3       5
7       11      13
17      19      23      29
31      37      41      43      47

using for loops with a video explanation maybe.

kinetickms