hi! need advice with this task
Write a function that receives an integer and if the integer is larger than 1, it print out its factors.
The function prototype will look like: void printFactor (long unsigned int number);
For example, if number is 24, this function should print 2 2 2 3
For any prime number like 13, it should only print the number itself.
Use this function to write a code that gets a number from the user and prints its factors until the user enters 0.
A sample run of your code should look like:
Please enter a positive integer number (0 to end): 12
Factors of 12 are: 2 2 3
Please enter a positive integer number (0 to end): 1000
Factors of 1000 are: 2 2 2 5 5 5
Please enter a positive integer number (0 to end): 17
Factors of 17 are: 17
Please enter a positive integer number (0 to end): 81
Factors of 81 are: 3 3 3 3
Please enter a positive integer number (0 to end): 0
Thanks and have a good day!
I understand the main idea (attached picture) but I stacked.
started with a first loop, but I only have an endless loop
Code:
#include<stdio.h>
int main(void)
{
int i;
int number =8;
for(i=2; i<number; i++)
while(number%i==0)
printf("\n%d", i);
}