Write a function that keeps computing the sum of the digits of x^n, until there is only one digit left. For example, sumOfDigits(2,5) returns 5, because 2 ^ 5 = 32 = 3 + 2 = 5 Another example, sumOfDigits(2,8) returns
Q: define the following function: This function accepts a string as its only parameter, and it must…
A:
Q: Using foldl, define a function num2int :: [Int] -> Int -> Int that converts a list of numbers and…
A: The most basic thing you could do is check if x=floor(x), Here floor returns the integer part of a…
Q: Define a function CalcPyramidVolume with double data type parameters baseLength, baseWidth, and…
A: The volume of a pyramid is the space that a pyramid occupies.
Q: For this program, I would like you to create a function which returns a character value based on a…
A: For this program, I would like you to create a function which returns a character value based on a…
Q: Write a function that receives the left, bottom, right and top coordinates of two rectangles, and…
A: Given : Rectangles are given as follows:intersection(l1,b1,r1,t1,l2,b2,r2,t2)where,l1 -> left of…
Q: Write a function that takes a two-digit number and determines if it's the largest of two possible…
A: 1. Created the new method and passing Number argument2. Created the new variable Newnum3. Perform…
Q: Write a function “func(n)” that returns the number of values generated until all values are obtained…
A: To write a function that returns the number of values generated using Harmonic.
Q: Write a function that makes the first number as large as possible by swapping out its digits for…
A: function maxPossible(n1, n2) { arr1 = n1.toString().split('') arr2 =…
Q: Write a function that asks the user how many Fibonacci num- bers to generate and then generates…
A: In the below step you can find the complete code.
Q: ite a function named sumDigits which takes three parameters: f, t and x. sumDigits, then, finds the…
A: the program is an given beloe :
Q: Write a function grade2number that takes a student's letter grade (A, B, C, D, F) as a char and…
A: Solution :: Code in C++ Please see the screenshot below for better understanding…
Q: Write a program that contains a function that receives two nonzero positive integers that represent…
A: CODE-: Using C++ #include <iostream> using namespace std;int printeven(int l,int r) //function…
Q: 2. There is a defined function called multiplierSum(n) which returns the sum of all multipliers of a…
A: Program plan: Define function multiplierSum(n) which prints the sum of all multipliers of a…
Q: Write a program in Python with a function squareRoot(x, epsilon) that uses bisection search to…
A: CODE:- def squareRoot(x, epsilon): y = 1 while abs(x - y ** 2) >= epsilon: y = (y +…
Q: In Pyhton IDLE Write a function that takes the first 10 even numbers and adds them to the first 10…
A: => Find first 10 even numbers. => Find the first 10 odd numbers. => Write a function to add…
Q: es a substring with a new string. Example: >>> replace('The quick brown fox jumps over the lazy…
A: Given : Write a function that replaces a substring with a new string. Example:>>>…
Q: Write a function double power(double x, int n) that will compute xn
A: This question comes from Programming Language which is a paper of Computer Science. Let's discuss it…
Q: Example Write a function → double Formula1(int m, int n) + double Formula2(double x) to obtain m= 9…
A: #include <iostream> #include<math.h> using namespace std; //creating funtion Formula1…
Q: We can assign a value to each character in a word based on their position in the alphabet (a = 1, b…
A: We can assign a value to each character in a word based on their position in the alphabet (a = 1, b…
Q: Write a function def reduced (n): n is a positive int number, greater than 0. The digit 0 does not…
A: I have provided PYTHON CODE along with CODE SCREENSHOT and also provided OUTPUT…
Q: Write a function to replace all instances of character c1 with character c2 and vice versa. Examples…
A: Algorithm - Create a method with name doubleSwap with three argument. Loop over the string…
Q: Define a function which takes one parameter N, and use loop(s) to control and output a pyramid…
A: Hi there, Please find your solution below, I hope you would find my solution useful and helpful.…
Q: A company wants to transmit data over the telephone but is concerned that its phones may b tapped.…
A: Note: As you have not mentioned any programming language, I am writing the program in C++.…
Q: Write a function named sumDigits which takes three parameters: f, t and x. sumDigits, then, finds…
A: Code def sumDigits(f,t,x): for i in range(f,t+1): sum = 0 for digit in str(i):…
Q: A small college is thinking of instituting a six-digit student II number. It wants to know how many…
A: Answer is given below-
Q: Write a computer program using C++ to compute the expression (n*(2^m!)), Where n, m are positive…
A: #include<iostream> #include<math.h> using namespace std; int fact(int num)…
Q: Define a function CalcPyramidVolume with double data type parameters baseLength, baseWidth, and…
A: here a function is added called CalcPyramidVolume() for calculating the volume of the pyramid.…
Q: Write a value-returning function isVowel that returns the value true if a given character is a vowel…
A: Programming Language used: C++ Language C++ code for the given scenario is as follows: #include…
Q: Write a function called subsequence() that finds the longest common subsequence of two DNA strands.…
A: Program explanation: Declare the header files Declare and define the function to calculate the…
Q: Write a function longest_streak(string, char) that receives as parameters a strings and a character…
A: If same character is found start comparing all the latter values till new character is arrived…
Q: decimal and returns this value. The string consists of "." and "-" characters, where "." represents…
A: Please find the answer below :
Q: Write a function biggestBuried(s), which the parameter s is a string, and the function returns the…
A: 1) Below is program that define function biggestBuried(s), in which the parameter s is a string, and…
Q: Write a function to calculate the sum of all numbers from 1 to a given number x y = 1 +2 + 3 + ... +…
A: Python Code for above : def sumOfDigitsFrom1ToN(n): return n * (n+1) / 2 # call…
Q: Write a function called number_matrix (r,c) that takes two parameters r and c and PRINTS ON THE…
A: The matrix is a rectangular arrangement of numbers or data. In a matrix, the horizontal entries…
Q: sumDigits, then, finds the smallest integer between f and t (both inclusive) whose sum of digits is…
A: function sumDigits(f,t,x): Start for f to t follow steps 3 to 8 n=i sum=0 while n>0 follow steps…
Q: Write a function that takes two integers and returns True if the integers have a common divisor that…
A: Required: Write a function that takes two integers and returns True if the integers havea common…
Q: Write a program to calculate n! for a given number n and perform the simple calculator operations.…
A: I'm given a Working code implemented in C and appropriate comments are provided for better…
Q: Create a function that takes in an integer n and returns the least commonly occurring non-zero…
A: Here I have first of all defined the function with an empty list. Now in the function, I have used…
Q: Write a function that receives the left, bottom, right and top coordinates of two rectangles, and…
A: the answer is an given below ;
Q: Write a function future-date which takes four integer parameters: year, month, day and num-days. It…
A: You'd have to pick a reference year, say 1600, and then make the input invalid if the user enters a…
Q: Write a computer program using C++ to compute the expression (n*(2^m!)), Where n, m are positive…
A: Functions in C++ are a block of statements which perform a specific task. Function has three parts:…
Q: Write a function that receives the left, bottom, right and top coordinates of two rectangles, and…
A: Program for given condition :- def intersection(l1, b1, r1, t1, l2, b2, r2, t2): """ Function…
Q: 3. Write a function TrapezoidalRule.m which takes three input arguments f, a and b and returns one…
A: function [I] = TrapezoidalRule(f, a, b)% This function calculates the integral of a function, f,…
Q: Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the…
A: Python Source Code: def swap_values(user_val1, user_val2): temp = user_val1 user_val1 = user_val2…
Q: Write a program that works with fractions. Your program should be able to add,subtract, multiply,…
A: PROGRAMMING APPROACH: Define the necessary header file using namespace. Define the function…
Q: This sequence of numbers can start with any positive number n. s is the sum of the individual digits…
A: Solution: Python code: def deadEnd(n): s=0 res=[] c=0 for i in str(n): s +=…
Q: function [P, A] = rect(L, W) P= 2 (L+ W); A=L W; end Above function is defined to find perimeter and…
A: The function is rect and it is accepting two parameters length and width and returns perimeter and…
Q: Write a function that adds two digit-strings in base b, where 2 <= b <= 10. Each string may be as…
A: Here have to determine about c++ Code for given problem of add 2 digit number.
Q: /* Write a function `coinProblem` that takes * 3 arguments: N, M and K; and solves following *…
A: PROGRAM EXPLANATION: Include the header file. Define a function coin problem(), this function will…
Write a function that keeps computing the sum of the digits of x^n, until there is only one digit left. For example, sumOfDigits(2,5) returns 5, because 2 ^ 5 = 32 = 3 + 2 = 5 Another example, sumOfDigits(2,8) returns 4, because 2 ^ 8 = 128 = 1 + 2 + 8 = 13 = 1 + 3 = 4
Step by step
Solved in 4 steps with 2 images
- Write a function timestable(n), which prints a multiplication table of size n. For example, timestable(5) would print: 1 2 3 4 5 2 3 4 5 4 6 8 10 6 9 12 158 12 16 2010 15 20 25Use the function in a program where you ask the user for n and you print the corresponding table.Write a function called repeater(s1, s2, n) that given two strings s1 and s2 and an integer n returns a string that starts with an underscore ('_'), then s1 and s2 alternate n times, then ends with an underscore. Please do not use loops.Write a function to check if a given input number is a jumping number. A number is called jumpingnumberif all adjacent digits in it differ by 1. All single digits are considered as jumping numbers. Some examplesof jumping numbers are 0, 5, 10, 12, 78, 567, 101.
- Write a program in python with a function repeatPhrase(phrase, n), which prints the given phrase n times, alternating between lowercase and uppercase. For example, repeat('The sky is yellow', 5) would print: the sky is yellow THE SKY IS YELLOW the sky is yellow THE SKY IS YELLOW the sky is yellow Use the function in a program where you ask the user for the phrase and the value of nWrite a function in C programming language that gets two ints x and y, and returns the sum of all ints between x and y, including them. int sum_interval(int x, int y); For example: - sum_interval(1, 4)returns 1+2+3+4=10. - sum_interval(10, 3)returns 3+4+5+6+7+8+9+10=52. - sum_interval(2, -1)returns (-1)+0+1+2=2. - sum_interval(-1, -1)returns -1. Note that we may have x>=y or x<=y. You may assume that the sum will be within the range of int.Write a Python function power(f,n) that takes a function f and an integer n, and returns a function that applies the function f to its argument n times. For example: power(f,0)(x) = x # apply f over x zero time = no application power(f,2)(x) = f(f(x)) # apply f over x twice, same as twice(f) power(f,5)(x) = f(f(f(f(f(x))))) # apply f over x five times If we have the function: def incr(x): return x+1, and x=5, then the above three calls would be, power(incr,0)(5) # => 5 power(incr,2)(5) # => 7 (apply incr over 5 twice) power(incr,5)(5) # => 10 (apply incr over 5 five times)
- Using foldl, define a function num2int :: [Int] -> Int -> Int that converts a list of numbers and the number n into an integer of base n. >num2int [3,4,5,6] 10 3456 >num2int [1,1,0,1,0,0,0,1,0,1,0,1,1,0] 2 3456 num2int :: [Int] -> Int -> Int num2int x y = foldl (\acc (a,b) -> ___a___ + b*y^a) 0 (___b___ (\x y ->(x,y)) [0..] (___c___ x)) fill in blank spaces of a , b , and cCreate a sum to(n) function in Python that returns the sum of all integer values up to and including n. Sum to(10), for example, would yield 55 as 1+2+3...+10.Write a Python function that takes a sequence of characters and determines if there are any pairs of characters that are not adjacent to each other by returning True if there are any pairs, or False Example: The string “abbot” would return False because the two b’s are adjacent to each other while the string “abba” would return True because, even though the two b’s are adjacent to each other, the two a’s are not.
- Write a function that takes a string representing the binary representation of a number, computes the number in decimal and returns this value. The string consists of "." and "-" characters, where "." represents 1 and "-" represents 0. For example, ".--.." corresponds to 10011, which is equal to 1 * 16 + 0 * 8 + 0 * 4 + 1 * 2 + 1 * 1 = 19. So the function returns 19 for an input of ".--..". """Write a function find_phone_numbers(text, code='357') that uses a regex to find and extract all the Cypriot phone numbers in a given text sequence. A valid Cypriot phone number starts with either 00 or + followed by the country code 357 and afterwards, 8 numeric digits. Examples: >> find_phone_numbers("""dkdkkdldld +35799394903 dkdkfk 0035799802358 fkfkfld.\n dldld;s;sdd dkdk +30690040404 and +3579933040""") ['+35799394903', '0035799802358'] and also Write a function is_zip_code(zipcode) that uses a regex to test if a given string evaluates to a correct zip code. A correct zip code has a length of 6 characters with the 3 first being letters and followed by 3 digits. Examples: is_zip_code('ABC123') -> True is_zip_code('FYA598') -> True is_zip_code('wyz940') -> True is_zip_code('AB123') -> False is_zip_code('ABCD123') -> False is_zip_code('ABC12') -> Falsewith Python Write a function that will allow the user to scramble a sentence given a stride, take the first portion for the stride, then the next portion for the given stride.... for example, Eric Charnesky with stride 4 #e rkrcnyihecas #'e r i c c h a r n e s k y' # 0 1 2 3 4 5 6 7 8 9 10 11 12 13