6- You have two numbers ABCD and WXYZ (ex: 2345 and 7965). Write an algorithm using Pseudocode that decides whether ABCD is the inverse of WXYZ. (For example, if ABCD is 2356 and WXYZ is 6532 then the algorithm prints "Inverse" otherwise it will print "Not Invers")
Q: A palindromic prime is a prime number and also palindromic. For example, 131 is a prime and also a…
A: Since programming language not mentioned, using C++
Q: Assume that start and end are integers. Return the average all of the numbers from start to end…
A: def average(start,end): avg = (start+end)/2.0 return avg x = average(3,5)print('The average is…
Q: A triangle is considered valid if the sum of each 2 sides is greater than the remaining third side.…
A: We have to write a program a program that takes the length of three sides and print "equilateral",…
Q: Eulers number e is used as the base of natural logarithm. It may be approximated using the formula…
A: NOTE : As the question is not specific about the programming language to be used to write the…
Q: This sequence will never reach 1, and so the number 11 is called unhappy. Given a positive whole…
A: Find the required code in java given as below and sample output :
Q: n integer is called squarefree if it is not divisible by any perfect squares other than 1. For…
A: Required: An integer is called squarefree if it is not divisible by any perfect squares other than…
Q: 23. A perfect number is a positive integer that is equal to the sum of its positive divisorsexcept…
A: The below given java program will obey the following rubrics:Importing essential header…
Q: Sales are paid based on an annual salary rather than an hourly wage. However, some employees are…
A: Here we take a simple ipo chart for this problem. ================================= Keep in mind…
Q: This sequence will never reach 1, and so the number 11 is called unhappy. Given a positive whole…
A: I give the code in Javascript along with output and code screenshot
Q: The GCD (Greatest Common Divisor) of two numbers is the largest positive integer number that divides…
A: Given:
Q: Fibonacci numbers have a lot of numerical properties. A few can be mentioned is that the squares of…
A: Fibonacci numbers have a lot of numerical properties. A few can be mentioned is that the squares of…
Q: Count the number of occurrences of substrings "baba" or "mama" * in the input string recursively.…
A: Algorithm: Start the program. Read the string and substring to find. Using split function find the…
Q: Fibonacci Series always starts with 0 and 1, or in other words the first two terms of this series…
A: Algorithm: Step 1: declare two variable first and second Step 2:intizllize first=0 and second =1…
Q: Computers are playing an increasing role in education. Write a program that will help an…
A: code into HTML:
Q: Write an algorithm to find maximum of n numbers.
A: In the given question we need to obtain the Maximum Number from n Numbers. For this , we would use…
Q: Create a Guessing Game, you should have your own number value, for example 58.
A: guessing the number game
Q: 4. A taxicab number is a sum of the cubes of two numbers such that the smallest of them divides the…
A: Below are the algorithm and the C program to find the taxicab number with two integers: - Algorithm:…
Q: The number of permutations of a set of n items taken r at a time is given by the following…
A: Program code: //include the required header file #include<iostream> using namespace std;…
Q: Assighme Heads or Tails? It is said that a perfectly fair coin will return heads 50% of the time,…
A: heads or tails :
Q: Square of 13 is 169. 31, which is a reverse of 13 has a square 961. Here are few numbers which have…
A: // Following C Program will give required Output #include <stdio.h>int reverse(int n){…
Q: age, write a
A: #include<stdio.h> int main (void){ int array[] = {1,6,15,9}; int length = sizeof array /…
Q: 4. A taxicab number is a sum of the cubes of two numbers such that the smallest of them divides the…
A: //include the required header file #include <iostream> using namespace std; //definition of…
Q: A perfect number is a positive integer that is equal to the sum of its positive divi- sors except…
A: code:- function output = perfectNumbers(n)output = zeros(1,n);for i = 1:ntest = 1:i-1;if…
Q: // this solves the area of a circle #include #define PI3.1415927 double Area(double r) double…
A: We need to debug the given c++ code and correct it.
Q: Complete the following program that collects an input word from the keyboard and finds if the word…
A: According to the asked question, the solution is given below with a proper explanation.
Q: The aim of Part 2 is to set up the puzzle for the player to solve in Part 3.
A: import java.io.*; import java.util.*; public class Main { public static void generateTest(int…
Q: 29. The number of combinations Chr of taking r objects out of n objects is given by: n! r!(n-r)! Cnr…
A: To find the number of combinations(C59,5 * C35,10 in the powerball lottery. Factorial(n) is a…
Q: -Write the algorithm and the Pseudo code for the following the questions? 1. Write an algorithm to…
A:
Q: This sequence will never reach 1, and so the number 11 is called unhappy. Given a positive whole…
A: As you have not mentioned any specific language so i provide the code in Python along with output…
Q: 2) Calculate y = x³ – 3x + 12 for x = [0, 1, 2, –3,–6, 200, –9] , print rules given below and y…
A: C++ Code for the given expression for all values of x #include <iostream> using namespace std;…
Q: Write an algorithm that lets the user enter several items prices (number of items is unknown)(when…
A: 1)Start 2)initialize number_of_items=0;sum_of_all_prices=0;highest_price=0;lowest_price=100000…
Q: A positive integer is called a perfect number if it is equal to the sum of all of its positive…
A: program code: import java.util.*;public class Main { public static void main(String[] args) {…
Q: A perfect number is a positive integer that is equal to the sum of its positive divi- sors except…
A: Answer: % Create perfectNum() function function myNum-perfectNum(num) %num=10000 if you want four…
Q: the use of .length and the importance of string) please explain the use of .length in this…
A: .length() is built in function used to find length of a string. Suppose a str ="abcde",then…
Q: Lets play a magic game. Pick any 4 digits integer, for example n = 1965. Perform following…
A: This program is implemented to split the integer into individual digits. Then sort the digits in…
Q: This sequence will never reach 1, and so the number 11 is called unhappy. Given a positive whole…
A: A happy number is defined as a number that is the sum of the squares of its digit will result in 1…
Q: The number of permutations of a set of n items taken r at a time is given by the following…
A: Objective: This program asks the user to input the number of students in a class and the number of…
Q: Write a program that displays all possible combinations for picking two numbers from integers 1 to…
A: Her is the Java program: public class Combinations{ public static void main(String[] args) { int…
Q: if characters ‘Y’, ‘R’ and ‘B’ represents the primary colors Yellow, Red and Blue; this algorithm…
A: if characters ‘Y’, ‘R’ and ‘B’ represents the primary colors Yellow, Red and Blue; this algorithm…
Q: (Compute e) You can approximate e* using the following series: x? x ex = 1 + 1! 2! 3! 4! n! Write a…
A: PROGRAM CODE: #include <iostream> // include header file for input output…
Q: This program reads a given set of integers and then prints the number of odd and even integers. It…
A: /*Program reads a given set of integers and then prints the number of odd, even, zeors, positive and…
Q: Write an algorithm that asks the user to enter an integer number then prints the sum of even digits…
A: Aim: To create a program that print addition of all the odd digits of a number and even digits of…
Q: Lottery.java, to generate a lottery of a two-digitnumber. The two digits in the number are distinct.…
A: Objective: This program generates a lottery game in which the user inserts a two-digit number that…
Q: Write Psuedo-code of an algorithm that will repeatedly ask the user to enter a number 10 times. If…
A: Psuedo code is step by step written outline that can be easily translated into the program.
Q: Question 4: Write an algorithm that asks the user to enter an integer number then prints the sum of…
A: Simple Algorithm to find sum of all digits of a number: Step 1: Get number by user Step 2: Get the…
Q: “Days into the year algorithm (C++)” Write a pseudo code for an algorithm to determine the number of…
A: Objective: Pseudocode needs to be written to input a date in the format YYYY-MM-DD and displays the…
Q: Q2. Write a program that reads the value of a positive integer n and prints the total number of…
A: Since the programming language is not mentioned so I have used the C++ programming language.…
Q: The algorithm read 2000 numbers (positive and negative). Your algorithm has to print either…
A: I am writing this code in C++
Q: wite an algorithm and draw a flouchart that lets the user enter a series of positive integers. APter…
A: Following is the C code #include <stdio.h> void main(void) { int A,B,C; printf("Enter…
Q: Combine the first name, middle name, and last name and assign it as the 'fullname' of the hero. If…
A: Implementing given program in C++.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
- The greatest common divisor of two positive integers, A and B, is the largest number that can be evenly divided into both of them. Euclid's algorithm can be used to find the greatest common divisor (GCD) of two positive integers. You can use this algorithm in the following manner: 1. Compute the remainder of dividing the larger number by the smaller number. 2. Replace the larger number with the smaller number and the smaller number with the remainder. 3. Repeat this process until the smaller number is zero. The larger number at this point is the GCD of A and B. Write a program that lets the user enter two integers and then prints each step in the process of using the Euclidean algorithm to find their GCD. An example of the program input and output is shown below: Enter the smaller number: 5 Enter the larger number: 15 The greatest common divisor is 5use JAVA to write the code. : Euclid’s algorithm for finding the greatest common divisor (gdc) of two numbers The algorithm: given two numbers, n1 and n2: Divide n1 by n2 and let r be the remainder. If the remainder r is 0, the algorithm is finished and the answer is n2. (If the remainder is 1, the numbers are mutually prime and we are done-see below.) Set n1 to the value of n2, set n2 to the value of r, and go back to step 1. Entering 0 for one of the values is bad. It should work for the other value, but you have to figure out which is OK and which is bad. Catch this problem as it happens and make the user enter another value until they enter an acceptable one. Give an appropriate error message if this happens.You have N magical bags of candies in front of you. The ith bag has A; candies in it. It takes you one minute to finish a bag of candies, no matter how many candies are in it. Every time you finish a bag with X candies in it, the bag is magically replenished with X/2 (rounded down to the nearest integer) more candies. Write an algorithm that determines the maximum number of candies you can eat in K minutes. Also determine the time complexity of your algorithm in the worst case situation. The input is a sequence of integers. The first integer N is the number of bags. The next integer K is the number of minutes you have. The next N integers is the number of candies in the bags. The output of your program is a single integer which represents the maximum number of candies you can eat. If the input is 5 3 2 1 7 4 2. the output would be 14.
- Find the numbers that can be expressed as the product of two nonnegative integers insuccession and print them in increasing order. (For example, 30 is such a number as it can bewritten as the product of 5 and 6 (30=5x6), which are two numbers in succession.) The user shouldspecify a maximum value and the program should print all said numbers smaller than or equal tothat value. The program should keep a count of how many numbers were printed and should output that count ,as well as the numbersFind the numbers that can be expressed as the product of two nonnegative integers insuccession and print them in increasing order. (For example, 30 is such a number as it can bewritten as the product of 5 and 6 (30=5x6), which are two numbers in succession.) The user shouldspecify a maximum value and the program should print all said numbers smaller than or equal tothat value. The program should keep a count of how many numbers were printed and shouldoutput that count, as well as the numbers. creat a git bash script for the problem aboveIn mathematics, a prime number is a natural number greater than 1 that is not a product of two smaller natural numbers, i.e. is it has only two factors 1 and itself. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1, involve 5 itself.Note that the prime number series is: 2, 3, 4, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, …a. Write a Java method named isPrime that takes a natural number as a parameter and returns the if the given number is prime or not using the following header: Public static boolean isPrime(int num) b. Write a Java class called PrimeNumbers that: o Reads from the user a natural value n (should be less than or equal 200). o Prints a list of the prime numbers from 2 to n and their number and values. o The program has to work EXACTLY as given in the following sample run.
- In mathematics, a prime number is a natural number greater than 1 that is not a product of two smaller natural numbers, i.e. is it has only two factors 1 and itself. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1, involve 5 itself.Note that the prime number series is: 2, 3, 4, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, …a. Write a Java method named isPrime that takes a natural number as a parameter and returns the if the given number is prime or not using the following header: Public static boolean isPrime(int num) b. Write a Java class called PrimeNumbers that: o Reads from the user a natural value n (should be less than or equal 200). o Prints a list of the prime numbers from 2 to n and their number and values. o The program has to work EXACTLY as given in the following sample run.Hints: • You should create a single dimension array to store the prime…Correct answer will be upvoted else downvoted. Computer science. You are given an integer n. Check if n has an odd divisor, more noteworthy than one (does there exist such a number x (x>1) that n is separable by x and x is odd). For instance, assuming n=6, there is x=3. Assuming n=4, such a number doesn't exist. Input The primary line contains one integer t (1≤t≤104) — the number of experiments. Then, at that point, t experiments follow. Each experiment contains one integer n (2≤n≤1014). If it's not too much trouble, note, that the input for some experiments will not squeeze into 32-cycle integer type, so you should use no less than 64-digit integer type in your programming language. Output For each experiment, output on a different line: "Indeed" if n has an odd divisor, more noteworthy than one; "NO" in any case. You can output "YES" and "NO" regardless (for instance, the strings yEs, indeed, Yes and YES will be perceived as certain).Tiling: The precondition to the problem is that you are given threeintegers n, i, j, where i and j are in the range 1 to 2n. You have a 2n by 2n squareboard of squares. You have a sufficient number of tiles each with the shape . Your goalis to place nonoverlapping tiles on the board to cover each of the 2n × 2n tiles except forthe single square at location i, j. Give a recursive algorithm for this problem in whichyou place one tile yourself and then have four friends help you. What is your base case?
- A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon is Area = ( n * s2 ) / (4 * tan( π/n) Here, s is the length of a side. Write a program that prompts the user to enter the number of sides and their length of a regular polygon and displays its area.Write an algorithm that reads 10 integer numbers and calculates the average for numbers that are divisible by 5.In mathematics, a prime number is a natural number greater than 1 that is not a product of two smaller natural numbers, i.e. is it has only two factors 1 and itself. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 x 1, involve 5 itself. Note that the prime number series is: 2, 3, 4, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, .. a. Write a Java method named isPrime that takes a natural number as a parameter and returns the if the given number is prime or not using the following header: Public static boolean isPrime (int num) b. Write a Java class called PrimeNumbers that: Reads from the user a natural value n (should be less than or equal 200). Prints a list of the prime numbers from 2 to n and their number and values. The program has to work EXACTLY as given in the following sample run. Hints: You should create a single dimension array to store the prime…