Unable to execute the program (no compilation error)
Alexie Chong
Greenhorn
Joined: Sep 16, 2011
Posts: 3
posted
0
Dear experts,
I am doing my assignment on finding how many numbers in N digit satisfy K requirement.
However, when i am testing the code, i could compile it but i couldn't execute it.
I am wondering if i made mistake in the as when i comment this out, my program is able to execute,though i didn't get the right output value
Please kindly enlighten me.
Logic of my codes (example):
N = 15, K = 3
When N = 1, result = 0 + (N%10)
= 0 + (1%10)
= 1
y = N/10
= 1/10
= 0
x = 1 + 0
= 1
return x = 1
if (sumOfDigits(1) == K)
noOfNoSatisfy ++;
----------------------------------------------------
In the case of above, noOfSatisfy still remains as 0
-----------------------------------------------------
When N = 12, result = 0 + (N%10)
= 0 + (12%10)
= 2
y = N/10
= 12/10
= 1
x = 1 + 2
= 3
return x = 3
if (sumOfDigits(3) == K)
noOfNoSatisfy ++;
----------------------------------------------------
In the case of above, noOfSatisfy increase and plus 1
-----------------------------------------------------
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
4
posted
0
Welcome to the Ranch
What goes wrong when you try that code? You have to tell us the full details, otherwise we can't help.
Alexie Chong
Greenhorn
Joined: Sep 16, 2011
Posts: 3
posted
0
I used to have issue in getting the desired output which i want. Then i realized i made a mistake with the algorithim and have worked it out just fine.
Thanks so much for helping anyway
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
4
posted
0
So what was the error?
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Unable to execute the program (no compilation error)