factors using recursion
C
/* C Program to print prime factors*/
#include<stdio.h>
void PFactors( int num);
void IPFactors( int n);
int main( )
{
int num;
printf("Enter a number : ");
scanf("%d", &num);
printf("\nUsing Recursion :: \n");
PFactors(num);
printf("\n");
printf("\nUsing Iteration :: \n");
IPFactors(num);
printf("\n");
return 0;
}/*End of main()*/
/*Recursive*/
void PFactors( int num)
{
int i = 2;
if( num == 1 )
return;
while( num%i != 0 )
i++;
printf("%d ", i);
PFactors(num/i);
}/*End of PFactors()*/
/*Iterative*/
void IPFactors( int num)
{
int i;
for( i = 2; num!=1; i++)
while( num%i == 0 )
{
printf("%d ", i);
num = num/i;
}
}/*End of IPFactors()*/
Also in C:
- Title
- how to put a struct in another struct C
- Category
- C
- Title
- div
- Category
- C
- Title
- hello world
- Category
- C
- Title
- c hello world
- Category
- C
- Title
- write a program to ask the user 8 integer numbers. your program will then move all negative elements of your array to the end of the array without changing the order of positive elements and negative elements
- Category
- C
- Title
- How to pull images from Docker Registry
- Category
- C
- Title
- ModuleNotFoundError: No module named 'tensorboardX'
- Category
- C
- Title
- delete string function in c
- Category
- C
- Title
- how to put quotes inside string c
- Category
- C
- Title
- what is x:Name Xamarin forms
- Category
- C
- Title
- CL/cl.h: No such file or directory
- Category
- C
- Title
- tar cmd
- Category
- C
- Title
- Switch Mode C Programming
- Category
- C
- Title
- Declare macro
- Category
- C
- Title
- read from stdin c
- Category
- C
- Title
- command line arguments c
- Category
- C
- Title
- find string in all files powershell
- Category
- C
- Title
- how to get random numbers in c
- Category
- C
- Title
- c defined value sum
- Category
- C
- Title
- disable gnu++11 option
- Category
- C
- Title
- how to free a 2d array correctly
- Category
- C
- Title
- functions return type in c
- Category
- C
- Title
- c how to define a variable
- Category
- C
- Title
- allocate memory c
- Category
- C
- Title
- how to do matrix multiplication in c
- Category
- C
- Title
- how to print in c
- Category
- C
- Title
- buscar caracter
- Category
- C
- Title
- accessing elements 2D array using pointers
- Category
- C
- Title
- fibonacci series using recursion
- Category
- C
- Title
- get current used proxy windows 7
- Category
- C
- Title
- c if int
- Category
- C
- Title
- -> operator
- Category
- C
- Title
- read a binary file c
- Category
- C
- Title
- how to convert int in to const char in c
- Category
- C
- Title
- calculate max of three numbers using ternary operator in c
- Category
- C
- Title
- read a document in c getting name from console
- Category
- C
- Title
- ordenar un vector
- Category
- C
- Title
- how to check the size of a file in linux c
- Category
- C
- Title
- prime number
- Category
- C
- Title
- get a remote branch git
- Category
- C
- Title
- c fill 2d array
- Category
- C
- Title
- reset c array to zero
- Category
- C
- Title
- how to declare 2 d array using malloc
- Category
- C
- Title
- stack
- Category
- C
- Title
- function in c
- Category
- C
- Title
- scanf read line
- Category
- C
- Title
- how to ascii art in c
- Category
- C
- Title
- sue murry
- Category
- C
- Title
- last element from list javascript
- Category
- C
- Title
- docker logs follow
- Category
- C
- Title
- java.lang.SecurityException: Permission denied (missing INTERNET permission?)
- Category
- C
- Title
- v
- Category
- C
- Title
- fgets c
- Category
- C
- Title
- c zero out array
- Category
- C
- Title
- #include<stdlib.h>
- Category
- C
- Title
- File "h5py\h5g.pyx", line 161, in h5py.h5g.create ValueError: Unable to create group (name already exists)
- Category
- C
- Title
- how to download file in powershell
- Category
- C
- Title
- pass the pointer in C
- Category
- C
- Title
- how to free memory in c
- Category
- C
- Title
- code in c skipping over scanf
- Category
- C
- Title
- how to remove button decoration
- Category
- C
- Title
- resto de division recursiva
- Category
- C
- Title
- c printf right pad with space
- Category
- C
- Title
- Gemfile.lock`. It is likely that you need to grant write permissions for that path.
- Category
- C
- Title
- how to check where the last char is in a string c
- Category
- C
- Title
- inurl:fiu.edu math faculty
- Category
- C
- Title
- compare two chars c
- Category
- C
- Title
- c pause for 1 second
- Category
- C
- Title
- how to find the ith row of pascal's triangle in c
- Category
- C
- Title
- how to open chrome using cmd
- Category
- C
- Title
- duplicar cadena
- Category
- C
- Title
- es par
- Category
- C
- Title
- get configuration script window 7
- Category
- C
- Title
- code: 'EADDRINUSE', [0] errno: 'EADDRINUSE', [0] syscall: 'listen', [0] address: '::', [0] port: 5000
- Category
- C
- Title
- latex font sizes
- Category
- C
- Title
- declare integer c
- Category
- C
- Title
- c check if char is an operator
- Category
- C
- Title
- pi in c language
- Category
- C
- Title
- restapi
- Category
- C
- Title
- objective c swizzle method
- Category
- C
- Title
- text wrap terminal colour
- Category
- C
- Title
- c producer consumer pthread semaphore
- Category
- C
- Title
- strcat in c
- Category
- C
- Title
- write array of char to file in c
- Category
- C
- Title
- what are the causes of memory leaks in c
- Category
- C
- Title
- how to feed a char array to function in C
- Category
- C
- Title
- slug urls django
- Category
- C
- Title
- how to do Employing defensive code in the UI to ensure that the current frame is the most top level window
- Category
- C
- Title
- 'int' is not a subtype of type 'double' dart
- Category
- C
- Title
- what is the meaningof noremap
- Category
- C
- Title
- ‘uint64_t’ was not declared in this scope
- Category
- C
- Title
- how to open a website in c
- Category
- C
- Title
- what is conio.h
- Category
- C
- Title
- passing 'const char *' to parameter of type 'char *' discards qualifiers
- Category
- C
- Title
- jock cranley
- Category
- C
- Title
- Print the number 0 using write()
- Category
- C
- Title
- read files in c
- Category
- C
- Title
- slurm array job
- Category
- C
- Title
- append to list in c
- Category
- C
- Title
- c program to perform transpose of a matrix
- Category
- C