top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Given a number return the prime factor multiplication using C/Java?

+1 vote
451 views
Given a number return the prime factor multiplication using C/Java?
posted Jun 13, 2017 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
#include<stdio.h>

int get_factor(int number)
{
    int i = 1;
    int sum = 0;

    while(1)
    {
        sum+=i;
        if(sum == number)
        {
            return i;break;
        }
        else if(sum > number)
        {
            return 0;break;
        }
        i++;
    }
}

int main(void)
{
    int number;
    int ret;

    printf("Enter the number : ");
    scanf("%d",&number);
    ret = get_factor(number);

    if( ret != 0)
    {
        printf("%d is the factor of the %d",ret,number);
    }
    else
    {
        printf("the number dosent have factor");
    }

    getchar();
    getchar();
    return 0;
}
answer Jun 13, 2017 by Leon Martinović
Similar Questions
0 votes

Given a sentence and a word, remove all occurrences of the word in the sentence.

For example, removing “is” from the sentence “This is a boy.” becomes “Th a boy.”

+1 vote

For Example:
the prime divisors of 450 are 4,5,3,3,2.

+1 vote

Array: 2,5,8,9,6,7,11,13,15,16,18,19,31,33,37,45

OUTPUT

2 is a prime number in the array 
5 is a prime number in the array 
7 is a prime number in the array 
11 is a prime number in the array 
13 is a prime number in the array 
19 is a prime number in the array 
31 is a prime number in the array 
37 is a prime number in the array 
Min 2
Sum 123
...