# need to solve simple c problem

• 09-15-2012
raihan004
need to solve simple c problem
Problem Name: Y = MX
Everyone know that the equation of a straight line is Y = MX + C. But if C = 0, then the straight line is passing through the origin. Here I always put C = 0. So our equation will be always Y = MX. Straight line is a geometrical term but my problem is not geometrical. I just use the equation Y = MX. Since Y = MX, so Y is must be divisible by M and X, and for a specific value of Y and various value of M and X, the equation must be satisfy.
But in this problem we find (N) the number of M and X that satisfy the equation with condition M must be less than X (M16 = 1 * 16 (1<16) so it is countable.
16 = 2 * 8 (2<8) so it is countable.
16 = 4 * 4 (4 = 4) so it is not countable.
16 = 8 * 2 (8>2) so it is not countable.
16 = 16 * 1 (16>1) so it is not countable.

So your duty is to find out how many way to find M and X (M
Input: You have to provide an integer Y (1<=Y<=10000).

Output: You just print the value of N.

Sample input:
16

Sample output:
2

what output i'll get for following those input 128,500,666,1000,10000?
i need code and solution

i tried many time but can't get logic. how i improve my logic?
help to clera this program logic concept.:) ... Shift+R improves the quality of this image. Shift+A improves the quality of all images on this page.
Code:

```#include<stdio.h> int main() {         int a,b,c=1,i;     scanf("%d",&a);     for(i=2;i<=a;i+=2)     {         if((a%i)==0)         {         printf("%d ",i);         b=(a%i);         }         if(b>i)         c++;     }     printf("\n%d",c); }```
• 09-15-2012
root4
Quote:

i need code and solution
• 09-15-2012
raihan004
Quote:

Originally Posted by root4

sorry am new. can't i ask any problem solution code ? what is my fault?
• 09-15-2012
root4
Quote:

can't i ask any problem solution code ?
Indeed. You can get some help, here, with programming issues, but nobody is going to solve any assignment.
Work on your problem first, show us some code and possible problems you face, then we'll help.
• 09-15-2012
I have been feverishly looking for a silver platter with a gold rim - something suitable for the delivery of this code and solution.

All in vain.
• 09-15-2012
Salem
You can only get so far by looking at code.
The real learning starts when you actually try and write some yourself.

• 09-15-2012
raihan004
now i inlcude my tried attetmp code . now make me my code fullfill and make clear concept
• 09-15-2012
root4
1. Your assignment gives you explicit names for the objects so use them in your code, that gives a readability bonus (e.g. what you named "a" is "y").

You have all the pieces, but not composed correctly: to increment your counter (c), Y has to be divisible by your current M (Y%M==0) and that M must be less than (Y/M) so you have to merge your two conditionals.
I don't know why you increment M by 2.
• 09-15-2012
iMalc
The problem comes from asking the equivalent of "do it for me" when you should be asking the equivalent of "teach me".
• 09-16-2012
raihan004
[solved] problem solve
i solve this problem . if any wrong about my logic please repaly or notify me thanks all
Code:

```  #include<stdio.h> int main() {     int y,m,n=0,i,x=0;     scanf("%d",&y);     for(i=1;i<=y;i++)     {         if((y%i)==0)         { x=y/i;         if(x>i)         {             printf("%4d",i);         n++;         }         }     }     printf("\ntotal %d step need to do this",n); } :redface:```
• 09-16-2012
root4
Looks ok.