How to attempt?Question :Charles and the NecklaceCharles wants to buy a necklace in which:1. There is a minimum of 1 pearl and maximum of X pearls, such that each pearl has its ownmagnificent coefficient.2. The pearls should be in non-decreasing order of their magnificence power.You are given the maximum number of pearls in a necklace and the range of themagnificent coefficients of the pearls. Find the number of necklaces that can be made thatfollow the mentioned conditions.Input Specification:input1: Maximum number of pearls that can be used to form the necklaceinput2: Starting magnificent coefficient of pearlsinput3: Ending magnificent coefficient of pearlsOutput Specification:Return the number of necklace options possible as per given conditions.Example 1:input1: 1input2:4input3:5CodConso!​

Answers 1

Explanation:

import java.util.Scanner;

public class Main

{

static int c;

public static void main(String[] args)

{

c = 0;

System.out.print("Enter N : ");

int n = (new Scanner(System.in)).nextInt();

for (int i = 0; i < n; i++)

print(1, n, i, "");

System.out.println("The count is : " + c);

}

private static void print(int s, int n, int x, String p)

{

if (x == 0)

for (int i = s; i <= n; i++) {

System.out.println(p + i);

c++;

}

else

for (int i = s; i <= n - x; i++)

print(i + 1, n, x - 1, p + i + " ");

}

If you know the answer add it here!

Can't find the answer?

Log in with Google

or

Forgot your password?

I don't have an account, and I want to Register

Choose a language and a region
How much to ban the user?
1 hour 1 day 100 years