Menu
Question Index
...

Write a program to get the factors of a give number as an array.

Input Output
10 1, 2, 5, 10
15 1, 3, 5, 15
50 1, 2, 5, 10, 25, 50



class FactorsOfNumber
{
    public static void main(String s[])
    {
        int result[] = getFactors(50);
        
        System.out.print("The factors of 50 are : ");
        for(int i = 0; i < result.length; i++)
        {
            System.out.print(result[i] + ", ");
        }
        

    }


    public static int[] getFactors(int number)
        {
        }

}

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App