Determine all possible values of a positive integer P, such that P-1 has three divisors Q, R and S, with Q < R < S, such that: Q + R + S = P
I have written this program in java.
pubblic class Divisors
{
void main()
{
int a.b,c,ans;
for (int i=2;;i++)
{
for(int j=1;j<=i-1;j++)
{
if((i-1)%j==0)
{
a=j;
for(int k=1;k<=i-1;k++)
{
if((i-1)%k==0)
{
b=k;
for(int l=1;l<=i-1;l++)
{
if((i-1)%l==0)
{
c=l;
if((a+b+c)==i)
{ans=i;break;}
}
}
}
}
}
}
}
Syatem.out.print("The value of P is "+ans);
}
}
So this program gives the valus of P to be 13.