I'm still work with my Prefect Number problem. But still have a little problem, the problem asks show all the divisor like this"1 + 2 + 3"
I tried the use "+" in the function, but the problem is i only get "1 + 2 + 3 +"
Q1: How to get rid of the last "+"?
Q2: I'm still work on the divisor, hope somebody can show good ideas for the divisor.
Thank you.
Here's my code:
PHP Code:
#include <stdio.h>
#include <math.h>
double i, j, k, b, N;
double prefect();
double list (double N);
int main (void)
{
prefect();
system("pause");
return 0;
}
double prefect()
{
k = 2;
while(b <= 1000000000)
{
i=pow(2, k-1);
j=pow(2, k);
b=i*(j-1);
k++;
if (b <= 1000000000)
{
printf(" %.lf = %.lf * %.lf = ", b, i, j);
List(N);
}
}
return b;
}
//Comment: I'm still work on this divisor function, i really need help on this one//
double List (double N)
{
double Div = N;
while (--Div > 0){
if ((N % Div) == 0 )
printf ("%d +", Div);
}
}