info@meritcampus.com    +91-85006-22255
...
`

Write a program to print the factors of the given number. The numbers should be separated by comma.

Input (Integer) Printed Output (Commas are also important and there are no spaces in output)
3 1,3,
8 1,2,4,8,
24 1,2,3,4,6,8,12,24,

``` class PrintFactorsOfNumber {     public static void main(String s[])    {        printFactorsOfNumber(25);    }     public static void printFactorsOfNumber(int number)     { ```
```     } } ```
Topic:

### User comments below.All of them might not be correct.

compter he mili thi puchne ko
pta h na kitti intellignt hu m

Posted by Priyanshi Pk    2014-11-27 07:53:28

For(int i=1;i<=25;i++)
If(25%i=0)
System.out.print(i+",");
Else
Continue;

Posted by Rohit Hrthaker    2014-11-27 07:54:19

oook

Posted by Priyanshi Pk    2014-11-27 08:03:28

Kese kese log  cmnt krre...jb prog ni aate tow faaltu ke   cmnts mt kro ap....

Posted by Rohit Hrthaker    2014-11-27 08:10:56

For( int i=1;i<=number;i++)
{
if(number%i==0)
System.out.print(i+".");
}

Posted by Asma Mujtaba Khan    2014-11-27 09:14:10

Finding factors
1.Input a number
2 initialize a variable say i with 1
3 start loop
4 check if number%i=0 if yes then print i
5 iterate loop till i=number by incrementing i by 1 for each  iteration
6 end loop

Posted by Pooja Singh    2014-11-27 10:02:48

we have to get a number whose remainder is zero,then it becomes a factor of that input number.
we use modulus operator to get remainder
we use divide to get quotient
if rem=0
print
else
not a factor
say some x as input number
iterate with a loop up to 25 or say some N
for(int i=1;i<n;i++)
{
if(x%i==0)
print
else
skip

Posted by Sai Veerendra    2014-11-27 11:21:46

To write the code, the programmer should aware of definition of factor. A factor of a given number remainder should be zero (0). And also should aware of for loop.

Algorithm to find factors of given input:

Step 1 : Number is the given input, to which factors are to be calculated.
Step 2 : Initialize i which ranges from 1 to number.
Step 3 : check for each value of i if number mod i is 0. if number mod i is 0 then i is the factor of a given input .

Output must contain commas ( , ) And there must be no spaces between the factors. The comma ( , ) must be included in print method without any spaces.

Posted by Sai Ram    2014-11-27 17:12:03

in this program u need to find factors of given input number.we all know number 1 and same given input numbers  are factors of given number.so here u need to find factors of given number between 2 and number-1 .                                                               so here u need to print 1 first ,just print 1 without any calculation,and print the same number at the end .aft printing number put comma,                                                     use any loop condition and initialize one local variable to 2.thn give conditio oop need to iterate upto number-1,thn increment thn variable.                                                           inside loop give one if condition and check modulo of givn number with iteration variable value.if value quals 0 thn print the counter value and put comma.thn run the program u get correct result .

Posted by Maheshwari Natarajan    2014-11-27 18:12:46

This dose is now closed and the winners are Sai Ram,  for 'First Correct Comment', Pooja Singh,  for 'Second Correct Comment'. The 'lucky liker' is Maheshwari Natarajan. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2014-11-28 02:26:52

Hey I hv also writtn th corrct prgrm den y not me b th winnr

Posted by Asma Mujtaba Khan    2014-11-28 05:09:57

Wtf....y these guys are d winners every time....it's all planned....fuck this shit

Posted by Rohit Hrthaker    2014-11-28 07:26:59

Exactly...it's all planned#asma bloody folks

Posted by Rohit Hrthaker    2014-11-28 07:31:19

Please find the rules at http://java.meritcampus.com/program-hints and if you think it is planned, please feel free to unlike and stop participating.

Posted by Merit Campus    2014-11-30 15:42:17

sorry merit campus.... my answrs wre not acc to rules

Posted by Asma Mujtaba Khan    2014-12-01 04:26:22