def mulitpleSum(N,x,y):
i=1
s=0
#iterating from 1 to N
#checking if i is divided by x or y than add to s
while(i<=N):
if i % x==0 or i % y==0:
s=s+i
i+=1
return s
print("#1",mulitpleSum(10,2,3))
print("#2",mulitpleSum(25,7,8))
print("#3",mulitpleSum(15,1,12))
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me
Write a function that finds the sum of all numbers up to (and including) N that...
****python**** Q1. Write a recursive function that returns the sum of all numbers up to and including the given value. This function has to be recursive; you may not use loops! For example: Test Result print('%d : %d' % (5, sum_up_to(5))) 5 : 15 Q2, Write a recursive function that counts the number of odd integers in a given list. This function has to be recursive; you may not use loops! For example: Test Result print('%s : %d' % ([2,...
Algorithm that finds the sum of numbers from 1 to N (including N) for the entered number N write step by step.
1. Write a recursive function that computes the sum of all numbers from 1 to n, where n is given as parameter. Here is the method header: public static int sum (int n){...} 2. Write a recursive function that finds and returns the minimum value in an array, where the array and its size are given as parameters. Here is the method header: public static int minValue (int [] data, int size){...} 3. Write a recursive function that reverses the...
Python 3 Write a function oneSum which takes one input, n, and finds the sum: For example: >>> print (oneSum( 1)) which is 1-1. >>> print (oneSum( 2)) 12 Which is 111 12. print (oneSum(3 ) 123 Hint: think about each element of the sum (1, 11, 111, for example) represented as a sum of powers of 10: 111-100 + 10^1 + 10^2= 1 + 10 + 100 For example: Test Result print(oneSum(3))123 print (oneSum(4)) 1234 print(oneSum(e)) print(oneSum(1) 1 1
Use MATLAB to program the following: 9. The MATLAB built-in function primes (x) finds all the prime numbers less than x. Write a M-file function "addupprime" that will sum up all the prime numbers of an input number x. Run and show 2 test cases to demonstrate that your function file is correct.
Question 1a - Increasing Numbers in List - First Occurence(3 points) Write a function numIncreasing1(L) that takes as input a list of numbers and returns a list of the first sequence within that is increasing order, and has a length of at least 2. If no increasing sequential numbers are found, (ie. the input list is in descending order) then naturally a list of just the first value is returned. Increasing sequence means for a number to be valid it...
BlockPy: #33.8) Maximum Odd Use the Min/Max pattern to write a function maximum_odd that finds the highest odd value in the list (consumes a list of numbers and returns a number). Use the provided helper function is_odd (that consumes a single number and returns a boolean indicating whether it is true or false). Do not change the helper function is odd. Call your maximum_odd function on your favorite list of numbers Console Feedback: Instructor Feedback You cannot use the builtin...
Question 4-6 Please. Python 3.6. def main(). entered by a user. Write a program that finds the sum and average of a series of numbers he program should first prompt the user to enter total numbers of numbers are to be summed and averaged. It should then as for input for each of the numbers, add them, and print the total of the numbers and their average 2. Write a progra m that finds the area of a circle. The...
Write a C program to sum up all the odd numbers between a lower limit number and an upper limit number provided by a user. The requirements are: First, request the user to provide a lower limit integer number and an upper limit integer number that is larger than the lower limit number, and save them in variables lowerLimit and upperLimit, respectively. If the user has entered an upper limit number (upper Limit) that is NOT larger than the lower...
#Which function has the most parameters? def Menu(): print ("Your Name Main Menu") print("1. Sum") print("2. Product") print("3. information") print("4. Quit") def Sum(x): x= x* 2 y = 10 answer = x+y return x,y,answer def Product(w,z): answer = w*z print (answer) def Calc(a,b,c): return a*b*c Question options: Product Calc Menu Sum