2. There is a defined function called multiplierSum(n) which returns the sum of all multipliers of a positive number n. For example, if n=8, it will return 1+2+4+8=15. If this sum except for the number itself is equal to the number itself, this number is called ideal number. Write another function called maxMult(m) which should find the smallest ideal number that is bigger than or equal to m, using the function multiplierSum.
Q: 2. The function function1 is defined as following def function1(aNumber): for n in range (2,…
A: a. Objective of the function: The given function “function1” is used to check a range of numbers…
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 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 receives 3 assignment grades, a1, a2, a3, and a final grade, f, for a student…
A: #include <iostream> #include<cmath> using namespace std; double gradeCalc(int a1, int…
Q: Before class, we'd like you to define a function that takes one string as input and returns the…
A: Algorithm : repeat_string function : Step 1 : add the input string to itself to get the output…
Q: Write a function called Divisors which takes an integer and print all its divisors on the screen.…
A: Since no language is given in the question. I am using c++ langauge See below step
Q: A natural number is prime if it is greater than 1 and has no divisors other than 1 and itself.…
A: Below is the python code with explanation: - Explanation: - Defining the method Isprime(num) which…
Q: A natural number is prime if it is greater than 1 and has no divisors other than 1 and…
A: The below-given python program will obey the following rubrics: Defining a function IsPrime(), this…
Q: Write a function print_numbered_items (items) that takes a list of items and prints them one per…
A:
Q: The first and second numbers in the Fibonacci sequence are both 1. After that, each subsequent…
A: function fib(number): Start declare i, n3, n2, n1 Initialize n3 =1, n2 =1, n1= 1 for i = 2 to…
Q: Because of the outbreak of the Coronavirus (COVID-19), visitors from infested countries and regions…
A: The program is written in c
Q: Write a function with name 'sum' to find the result of mathematical function given below. Your…
A: int sum(int n,int m,int k){ int temp=0; if(m<n){ //swapping m and n if m<n…
Q: • Create a coin toss function that simulates tossing a coin (returns heads or tails). • Next, change…
A: Program: import random#Function which returns random tails and headsdef…
Q: Write a function in C programming language that gets two ints x and y, and returns the sum of all…
A: 1) Below is C Program that gets two ints x and y, and returns the sum of all ints between x and y,…
Q: Write a function called extractor() that takes a name as a parameter and counts every vowel present…
A: Program: Program is used to provide the instructions, it is used to interact with the computer…
Q: John is used to doing programming in Python and since the print() function in Python by default…
A: Write a function myecho() in PHP language that takes a string as the parameter and prints the string…
Q: Using the function from the previous problem, write a function durdle_game(target) which takes in as…
A: Please find the answer below :
Q: Write a program in python with a function perfectcube(n), which returns True if n is a perfect cube…
A: let us see the code:-
Q: Suppose that you have the following function definition. int find(int x, int y){return (x + y - x *…
A: (a) The function call u = find (list1[0], v); is valid. Explanation: An integer arrays list1[0] and…
Q: Write a function named `pairs(a,b,c,d)` that takes four integers as its input and checks whether…
A: Code:- def pairs(a,b,c,d): # you can use if-else conditional to decide # whether sum of one…
Q: Write a function which takes one parameter int num, and prints out a countdown timer with minutes…
A: Create a function that prints the countdown timer. The given signature of the function is: void…
Q: Exercise 6: Area of a Circular Sector Write a function area_of_circular_sector() which • takes 2…
A: In this program question using python We have to calculate area of circular sector using two…
Q: Write a function that accept limit as parameter and returns the sum of multiples of 3 or 5 between 0…
A: Since programming language not mentioned, using Java. import java.util.*; public class Main {…
Q: Find Relatively Prime Write a function to return a number that is relatively prime with the given…
A: Given number should be greater than 1 and less than n-1 A pair is said to relatively prime if both…
Q: Write a function called translate_to_italian () that takes a string as a parameter (a colour).…
A: # Python program to convert color in English to Italian word List=["Verde","Viola","Rosa","Argento"]…
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 count_evens() that has four integer parameters, and returns the count of parameters…
A: logic:- within function use if statement to check remainder when divided by 2 is 0 or not. count=0…
Q: . Find Relatively Prime Write a function to return a number that is relatively prime with the given…
A: Actually, function is a group of statements. The given information is: * return an integer that is…
Q: Write a function called translate_to_italian () that takes a string as a parameter (a colour).…
A: #you didn't specified the language. So i wrote in Python language. def translate_to_italian(colour):…
Q: Create a function that takes two integers, num and n, and returns an integer which is divisible by n…
A: As no programming language is mentioned, it is solved using basic Python
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: C++ ASAP plz First: Write a function to check whether a given number is a prime number. A prime…
A: Declare a variable number and read the value from the user. In the if statement, call the function…
Q: Create a function that determines whether a number is Oddish or Evenish. A number is Oddish if the…
A: function oddishOrEvenish(num) { let arr = num.toString().split(''); let sum =0; for (let i of arr){…
Q: Write a function that takes 4 Inter gets (num1, den1,num2,den2) as parameters which represent the…
A: define function check if bottom value is zero display message for invalid input else…
Q: Write a program BMI.py that performs the following, Define a function called getBMI that takes…
A: Question given - Define a function getBMI that calculate a person's BMI score based on person's…
Q: Write a function called translate_to_italian () that takes a string as a parameter (a colour).…
A: The program contains a function named translate_to_italian() that takes a string as parameter. Using…
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 function that converts a word or sentence to Pig Latin. It should be a function with one…
A: piglatin: Pig Latin is a language game in English in which words are altered according to the rules.…
Q: Write a function calculate_points that has a single input parameter: hand . hand can be assumed to…
A: Python function: #function to calculate the point on a hand def calculate_points (hand): #set…
Q: Write a function named "reduce" that takes two positive integer arguments (as reference), call them…
A: c++ Code for above : #include <bits/stdc++.h> using namespace std; bool reduce(int…
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: Write a function called translate_to_italian () that takes a string as a parameter (a colour).…
A: We chose C++ to execute this logic but this can be applied in any programming language.
Q: Write a function convertQuartersToDollars that has the noOfQuarters, noOfDollars, and remainingCents…
A: int convertQuartersToDollars (int noOfQuarters , int noOfDollars , int remainingCents ) { int…
Q: Some of the earliest computer games developed were Interactive Fiction games, in which the user’s…
A: Python Function: It is code defined in the block and it executed when it is called Python function…
Q: Create a function that takes an amount of monetary change (e.g. 47 cents) and breaks down the most…
A: 1. Create the method with a number argument. 2. Create the variable q and Divide it by 25. 3. Create…
Q: In this excersie the main function calls Series1 and/or Series2 functions and you are required to…
A: Code is given below #include <iostream> using namespace std; int fact(int n)…
Q: Write a function that keeps computing the sum of the digits of x^n, until there is only one digit…
A: Algorithm Start Var a, b Call function f=func(a, b) Print(f) Stop Function func(a, b) Start…
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…
Python
Step by step
Solved in 4 steps with 3 images
- Implement a function named root_sum which receive an integer and return the result of summing all the scare roots from 1 to the number passed in. For example, if the argument is 4, then the function returns 6.15 because √4 + √3 + √2 + √1 = 6.15. It doesn't need to print (√4 + √3 + √2 + √1 = 6.15), in fact the function shouldn't print anything, just return the final value, in this case 6.15. You may assume that #include <cmath> has already been included and you have access to the sqrt() function, which takes a single double or any value that can be converted to a double and returns that value's square root as a double. No error checking is necessary. Assume the user always passed in a value > 1. In c++ programWrite a generator function named count_seq that doesn't require any arguments and generates a sequence that starts like this: 2, 12, 1112, 3112, 132112, 1113122112, 311311222112, 13211321322112, ...To get a term of the sequence, count how many there are of each digit (in a row) in the **previous** term. For example, the first term is "one 2", which gives us the second term "12". That term is "one 1" followed by "one 2", which gives us the third term "1112". That term is "three 1" followed by "one 2", or 3112. Etc.Your generator function won't just go up to some limit - it will keep going indefinitely. It may need to treat the first one or two terms as special cases, which is fine. It should yield the terms of the sequence as **strings**, rather than numeric values, for example "1112" instead of 1112.Please answer it in Python Write a double_consonant function , It takes a word as a parameter and has two return values : A Boolean value equals True If the word contains a double consonant ( The same consonant twice in a row ), under these circumstances , The second value returned is the double consonant ; If there are no double consonants , Function should return False and None. relevant information : To simplify the exercise , We don't use words that contain multiple double consonants ( for example ,“successor”) Test your functionality on . Example : double_consonne('arrivee') vaut True, 'r'.double_consonne('bonbon') vaut False, Nonedouble_consonne('reussite') vaut True, 's'
- Write a program in Python with a function perfectcube(n), which returns True if n is a perfect cube and returns False otherwise. Notice that this function is not printing anything, but rather returning True or False. The function must use exhaustive enumeration to check if n is a perfect cube. Use the function in a program where you ask the user for n and you print a statement like "Yes, that is a perfect cube" or "No, that number is not a perfect cube".Please answer it in Python Write a function double_consonnant that takes as an argument a word and has two return values: a Boolean worth True if the word contains a double consonant (twice the same consonant in a row), and in this case the second return value is the consonant that is doubled; if there is no doubled consonant, the function must return False and None. If the word contains several double consonants (for example, 'successor'), true will be returned and the first double consonant appearing in the word. Examples: double_consonne('arrivee') is true, 'r'. double_consonne (‘bonbon’) is false, None double_consonne('appelle') is True, 'p'Create a program that accepts an integer N, and pass it to the function generatePattern. generatePattern() function which has the following description: Return type - void Parameter - integer n This function prints a right triangular pattern of letter 'T' based on the value of n. The top of the triangle starts with 1 and increments by one down on the next line until the integer n. For each row of in printing the right triangle, print "T" for n times. In the main function, call the generatePattern() function. Input 1. One line containing an integer Output Enter N: 4 T TT TTT TTTT
- Write program in python with a function occupy(n), which shows how birds are going to occupy n nests, assuming that each new bird will choose the nest in the middle of the largest unoccupied run of nests. For example, if there were 10 nests, occupy(10) would print out the following sequence, where underscore indicates an unoccupied nest, and X indicates an occupied nest. The first line of the printout is just 10 underscores showing that all the nests are unoccupied. The second line shows that a bird came to nest in position 5, since that is one the first middle positions of the unoccupied run from 0 to 9. In the third line a bird came to occupy the middle position for the longest open run of nests, from 0 to index 4.Write a function biggestBuried(s), which the parameter s is a string, and the function returns the largest integer buried in the string. If there is no integer inside the string, then return 0. For example, biggestBuried('abcd51kkk3kk19ghi') would return 51, and biggestBuried('kkk32abce@@-33bb14zzz') would return 33, since the '-' character is treated like any other non digit. Note that a character is a digit if it is greater than or equal to '0' and less than or equal to '9'. Alternatively, you can use string.isdigit() to check if the string is a digit. Use the function in a program to test that it works properly by saying print(biggestBuried('abcd51kkk3kk19ghi')) answer should be 51 print(biggestBuried('kkk32abce@@-33bb14zzz')) answer should be 33 print(biggestBuried('this15isast22ring-55')) answer should be 55Write 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.
- In Kotlin, write a higher-order function with an expression body that takes an int n and a function f from int to int and returns the result of calling f(f(n)). For example if you call the function with n = -5 anda function that calculates absolute value, your function will return 5, and if you send the value 2 and a function that calculates the sqaure of an int, the function will return 16. in addition to the function, write the syntax to call it with:a. a function name as the function arguementb. some lambda expression as the function argumentWrite a function that receives 3 assignment grades, a1, a2, a3, and a final grade, f, for a student and returns the corresponding letter grade of the student. The weights for the assignments and the final are 0.2, 0.2, 0.2, and 0.4, respectively. You can use the following table for matching grades to letters: 95-100 -> A1 90-94 -> A2 85-89 -> A3 80-84 -> B1 75-79 -> B2 70-74 -> B3 65-69 -> C1 60-64 -> C2 55-59 -> C3 40-54 -> D 0-39 -> F For example, compute_letter(80, 60, 40, 70) returns "C2" because 80 * 0.2 + 50 * 0.2 + 40 * 0.2 + 70 * 0.4 = 62 and 62 corresponds to C2. Note that, you are expected to do rounding. For example, 39.4 is F, whereas 39.5 is D. You can use the builtin round() function for this. Please google this function and learn how to use it. """Develop a code that gets two integers from the user and calculates and prints their least common multiplier or LCM. LCM is the smallest number that divides both given integers. Example. lcm (10, 15) = 30, lcm (5,7) = 35 and lcm (12, 24) = 24Hint: we know that lcm(x,y) = xy/gcd(x,y) where gcd is the greatest common divisor (discussed in class). Develop a gcd function in your code, get the two numbers from the user, call your function to calculate their gcd and then use the formula above to calculate and display their lcm GOOD LUCK! Reference This is a list of function prototypes of the C library functions presented in class. You may use any of these functions in your solutions (unless the requirements explicitly indicate otherwise). As you have been provided the function prototypes, you are expected to use the functions correctly in your solutions. double atof(char *string); int atoi(char *string); long atol(char *string); int fclose(FILE *filePointer); char *fgets(char…