Question

In: Computer Science

Problem DescriptionFind all numbers that when multiplied by 365 produce an eightdigit product where...

Problem Description

Find all numbers that when multiplied by 365 produce an eight digit product where the first four digits of that product are equal to the last four digits of that product. For example, 271123 time 365 produces an eight digit product (98959895) whose first four digits (9895) are equal to its last four digits (9895).

Input/Output

There is no input for this problem.

The output will be a list of the first ten integers that when multiplied by 365 create an eight digit product where the first four digits of that product are equal to the last four digits of that product. Also print the product of the number and 365. Submit a second version of your application that prints all the numbers (not just the first ten) so the judges can see the last ten numbers generated.

Sample Output

Output for a single random combination is listed below.

Number        Number * 365

......        ........

271123        98959895

......        ........

Solutions

Expert Solution

First Version:-


public class Product {
  
   public static void main(String a[]){
       int count=0;
       StringBuilder sb;
       /*Loop is started randomly from 10000, because product of no number below that with 365 would be of 8 digits */
       for(int i=10000;(i*365)<100000000; i++){
           if(i*365<10000000){
               //if product is less than 8 digits, we don't consider it
               continue;
           }
           else{
               sb = new StringBuilder();
               sb.append("");
               sb.append((i*365));
               String strI = sb.toString();
              
               if(strI.substring(0, 4).equals(strI.substring(4))){
                   count++;
                   System.out.println("Number \t " + "Number*365");
                   System.out.println(""+i+ "\t" + (i*365) );
                   if(count==10){
                       break;
                   }
               }
           }
       }
   }
}

Second Version:-


public class Product {
  
   public static void main(String a[]){
       StringBuilder sb;
       /*Loop is started randomly from 10000, because product of no number below that with 365 would be of 8 digits */
       for(int i=10000;(i*365)<100000000; i++){
           if(i*365<10000000){
               //if product is less than 8 digits, we don't consider it
               continue;
           }
           else{
               sb = new StringBuilder();
               sb.append("");
               sb.append((i*365));
               String strI = sb.toString();
              
               if(strI.substring(0, 4).equals(strI.substring(4))){
                   System.out.println("Number \t " + "Number*365");
                   System.out.println(""+i+ "\t" + (i*365) );
               }
           }
       }
   }
}

 


Related Solutions

C# Prime factors are the combination of the smallest prime numbers, that, when multiplied together, will...
C# Prime factors are the combination of the smallest prime numbers, that, when multiplied together, will produce the original number. Consider the following example: Prime factors of 4 are: 2 x 2 Prime factors of 7 are: 7 Prime factors of 30 are: 2 x 3 x 5 Prime factors of 40 are: 2 x 2 x 2 x 5 Prime factors of 50 are: 2 x 5 x 5 Create a console application with a method named PrimeFactors that,...
1: Marginal revenue product equals a. marginal revenue multiplied by marginal product b. marginal product multiplied...
1: Marginal revenue product equals a. marginal revenue multiplied by marginal product b. marginal product multiplied by total revenue c. total revenue multiplied by total product d. marginal revenue multiplied by total product 2: The long-run is a period of time a. during which at least one input is variable b. during which at least one input is fixed c. sufficient to vary all inputs in the production process d. greater than one year 3: Marginal cost equals a. average...
Risk may be assessed as the product of a disaster’s probability multiplied by the vulnerability and...
Risk may be assessed as the product of a disaster’s probability multiplied by the vulnerability and divided by the capacity to adequate response, a financial institution operating in Tampa (Florida) as compared to a financial institution in New York. What difference should they have in their risk plan towards disaster recovery and how will they ensure that customers will have access to their money when a hurricane comes through?
Write a method that returns the result when the calling object is multiplied by a scalar...
Write a method that returns the result when the calling object is multiplied by a scalar value. For example, the PolyTerm 2.4x^3 multiplied by -1.2 should return the PolyTerm object representing -2.88x^3. Language: Java. Method name be like: scalarMultiply(double) Some Outputs: Test 1: Coefficient =1, Exponent = 1 scalarMultiply(1.2).coefficient return 1.2; scalarMultiply(1.2).exponent returns 1. Test 2: Coefficient =2.4, Exponent = 3 scalarMultiply(-1.2).coefficient returns -2.88 scalarMultiply(-1.2).exponent return 3 Test 3: Coefficient =-1.5 Exponent = 0 scalarMultiply(0).coefficient returns 0 scalarMultiply(0).exponent returns 3...
a) A company can sell all the units it can produce of either Product A or...
a) A company can sell all the units it can produce of either Product A or Product B but not both. Product A has a unit contribution margin of $16 and takes two machine hours to make and Product B has a unit contribution margin of $30 and takes three machine hours to make. If there are 5,000 machine hours available to manufacture a product, income will be $10,000 more if Product A is made. $10,000 less if Product B...
Assume the health production function is h = 365 − 1/H, where h is the number...
Assume the health production function is h = 365 − 1/H, where h is the number of healthy days a person has in each year and H is the person’s health capital. Assume this person earns a wage of $100/day, and the marginal cost of health investment π = 25 and is constant over time. The annual interest rate is 5 percent, and health capital depreciates at a rate of 35 percent per annum. Find the optimal level of health...
Of all the numbers whose difference is 54, find the two that have the minimum product.
Of all the numbers whose difference is 54, find the two that have the minimum product.
In Python, Given a list of numbers, return a list where all adjacent == elements have...
In Python, Given a list of numbers, return a list where all adjacent == elements have been reduced to a single element, so [1,2,2,3,3,2,2,4] returns [1,2,3,2,4]. You may create a new list or modify the passed in list (set function does not work in this case).
A vector has components (4,2). When the vector is multiplied by the scalar 9, how does...
A vector has components (4,2). When the vector is multiplied by the scalar 9, how does its magnitude and direction change?
The seller of a product has no idle capacity and can sell all it can produce...
The seller of a product has no idle capacity and can sell all it can produce at $33 per unit. The incremental variable cost is $9. What is the lost opportunity (cost) if the seller transfers the units to another division? Question 6 options: a) $6 b) $ 0 c) $12 d) $33 e) $24
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT