Menu
Question Index
...


Write a program to print all the possible ages given the number of children and product of their ages. The possibilities should be sorted as shown below. Use System.out.print or System.out.println for printing.

Input (Integer, Integer) Printed Output
Number = 1, Product = 6 6
Number = 2, Product = 3 1 3
Number = 3, Product = 24 1 1 24
1 2 12
1 3 8
1 4 6
2 2 6
2 3 4
Number = 3, Product = 12 1 1 12
1 2 6
1 3 4
2 2 3
Number = 2, Product = 72 1 72
2 36
3 24
4 18
6 12
8 9

class PrintPossibleAgesOfChildren

{    public static void main(String s[])
    {
        printPossibleAges(3, 24);

    }


public static void printPossibleAges(int numberOfChildren, int productOfTheirAges) {
//Write a code here to print all the possible ages of children. Use System.out.println or System.out.print for printing.
}

//If required, write any additional methods here
}

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