Mathematics: Hatching of eggs
There is a fish pond in your garden.
On the first day, 1 fish egg hatches, and a fish is born.
On each consecutive day number of eggs that hatch is
twice the previous day.
For a given Nth day, print how many eggs will hatch on
that day?
Function Description
In the provided code snippet, implement the provided
twiceTheNumber(...) method using the variables to print
or return the output. You can write your code in the
space below the phrase "WRITE YOUR LOGIC HERE".
There will be multiple test cases running so the input and
Output should match exactly as provided.
The base output variable result is set to a default value
of -404 which can be modified. Additionally, you can add
or remove these output variables.
Answers
Answered by
0
Answer:
For the given program the solution is in java
Explanation:
// Solution in Java
import java.util.*;
import java.lang.*;
import java.io.*;
class Codewindow
{
public static void main (String[] args) throws Exception
{
// your code goes here
long eggs = (long)Math.pow(2, n-1);
System.out.println(eggs);
}
}
Implement the specified steps twice in the provided code snippet. TheNumber. The default value of the base output variable result, which is modifiable, is set to -404.
#SPJ2
Similar questions
Computer Science,
2 months ago
English,
2 months ago
Computer Science,
5 months ago
English,
11 months ago
Hindi,
11 months ago