4. The following algorithm gives a test if a given number is prime. Write a script to test it. Then try it out on the numbers: 4058879 (not prime), 193707721 (prime): (a) Input P (b) Initialize N to 3 (c) Find remainder R when P is divided by N (d) While R#0 and N < VP repeat: Increase N by 2 Find R when P is divided by N (e) If R#0 then P is prime Else P is not prime (f) Stop
Q: 30/30 *Write an algorithm to find the maximum of three values 1-Start 1-Start 2-Read X1,X2,X3 3- If…
A: Here, the correct answer is , 'option c'
Q: Write a VB.NET program to find sum of all natural numbers between 1 to N. 2. Write a VB.NET program…
A: Write a VB.NET program to find sum of all natural numbers between 1 to N. 2. Write a VB.NET program…
Q: Write a program that reads an integer value and prints the sum of all even integers between 2 and…
A: You didn't mention any programming language. So I use C++ language to write this program. C++…
Q: 6. What is printed by the following when executes? 1 str= "His shirt is red" 2 pos= str.find("is") 3…
A: Solution of question 6: Right answer - Option (D) 1 Explanation - Here find function of string is…
Q: Write a program that reads a positive integer number N in the range 0 < N ≤ 19. If ? is outside this…
A: Code : import java.util.*; public class RowColumnProgram{ public static void main(String[] args)…
Q: Given a number n, identify and print which in the given set of numbers are factors of n. Should…
A: The code in C++ is as follows #include <iostream> using namespace std; int main() { cout…
Q: Binary numbers need more places for counting because A. They are always big numbers B. Any no. of…
A: - We need to talk about the reason why binary numbers need more spaces in counting. - The options…
Q: Cody has a circle of friends of 5 people. To show his appreciation of them, Cody wants to be able to…
A: Note - As you have not specified the programming language, I have written the code in Java…
Q: 1- Start 2- Read n 3- Let S= 0 4- Let K = 1 5- Let S = S+K 6- Let K = K + 1 7- If K<n go to the step…
A: As per the question
Q: Given 5 input numbers, the algorithm below should calculate the sum of all the even input numbers.…
A: The problem is based on the algorithms in programming languages.
Q: m + n = 2k + 2k = 4k therefore adding even numbers always gives an even number. The above is wrong…
A: Yes , As we know that adding of two even is always a even number
Q: 14. Give an example of program that calculate the following sum: n k ΣΣ ij i=0 j=0
A: //C program #include<stdio.h> int main(){ int n,k;//store n and k printf("enter n and…
Q: Which of the following sets are equal to each other? а. А%3D {1,2, 3} b. B= {} C = {Hello, Hi, Good…
A: Two sets Y and Z, are said to be equal sets when every element of set Y exist in the set Z, and…
Q: Q3 :::: Write a Algorithms to calculate the value of (y) as following: if x>0 y=6/x y=X/6 if X < =0
A: 1) Start 2) Input x 3) if(x > 0) y = 6/x else y = x/6 4) Display y 5) Stop
Q: The following algorithm aims to return the negative of the absolute value of x (for example, if x 5…
A: Absolute value: An absolute value is the positive value of the number. If the number is positive…
Q: What is the resulting output for the following code? x = [0, 0.001, 0.01, 0.1] A exp(x) 1 = [ 0.…
A:
Q: Given the following series: P(n)= 1-1/2+1/3-1/4+1/5...+1/n Write a java program that prints out the…
A: PROGRAM CODE: import java.lang.*; // import java language packagepublic class…
Q: What is the value stored in y when the algorithm below is used on the input: 3, 2, 1, 0? proc noname…
A: The given code is a procedure in which an array of elements of size n. The array, consisting of 4…
Q: In C-language expression, how is not equal to represented? Select one: a. = b. all of the choices C.…
A: Find the answer with reason given as below :
Q: S= 53/yx+75/y*+97/yx +.. . %3D ....+n/y* For example, if n 9, then the product would be 53…
A: According to the information given:- We have to take input from user and implement the equation.
Q: What is the value stored in y when the algorithm below is used on the input: 3, 2, 1, 0? proc noname…
A: The algorithm initializes an integer type array "noname" of "n" number of elements. For an input…
Q: Create an algorithm which takes a positive integer n as an input then draws a cross on the screen…
A: Algorithm : 1. Enter value of n. 2. Create a loop for row from 0 to n*3. Such as i=0 to i<n*3 3.…
Q: Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's…
A: Given: Write a program that takes in a positive integer as input, and outputs a string of 1's and…
Q: Divide 5 by 4 in unsigned binary numbers, where each number is represented using 4 bits. The…
A: Objective: Given a flowchart to perform binary division using the restoring method. The result of…
Q: Write a program that reads N from the user and compute the following series: (N-1)-((N-2)^2) /8+…
A: using C++ language for this problem algorithm= styep-1 initialize the variable step2 generate a…
Q: Write a program that would print out a part of the multiplication table. Get as input the start…
A: Find Your Code Below
Q: The following algorithm gives a test if a given number is prime. Write a script to test it. Then try…
A: Following the given instructions, a matlab program is provided in the next step.
Q: double x - 2.5; double y - -1.5; int m = 18; int n- 4; a. x + n * y - (x + n) * y b.m /n +m % n c.…
A: 1. x + n * y ( x + n) * y = 2.5 + 4 * -1.5 ( 2.5 + 4) * -1.5 = 6.25 The answer for 'a' , if the…
Q: Solve the question using only a brute force algorithm. Explain your solution and question write…
A: Check the strings from the right end If the two characters at present to check are the same we…
Q: What is the output of following algorithm? function FRec Fread() j==0 i>5 + i=read() Fread() call…
A: Here, We have given complete flow of this algorithm
Q: The following incomplete code snippet: names ["Alice","Bob","Charlie"] scores = [15,5,10] winrates…
A: Please refer to the following steps for the complete solution to the problem above.
Q: Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's…
A: The program is to take a positive integer as input and output a string of 1's and 0's representing…
Q: 61. State true or false: If I = read(Q) and J = read(Q) then the order of I and J does not matter.…
A: The order will change if the operations are different.
Q: Suppose you have the following list of values, which of the following searching algorithm is faster…
A: In given list , searched element (9) is present at starting of list . In sequential search ,…
Q: Write a program that calculate the values of (X + Y) x (X – Y) where X, Y = 0, 1, 2, …, 9 and prints…
A: #include<iostream> using namespace std; int main(){ cout << "X|Y 0 1 2 3 4 5 6 7 8 9"…
Q: S1 = 'abcdefgh' S2 = S1 S1 = S1.replace('b', 'k') The value of the expression S1 == S2 is O True O…
A: The correct answer is False. replace() method in Python replaces a specified string with another…
Q: Write a program that takes in a positive integer as input, and outputs a string of 1's and O's…
A: Function IntegerToBinary(integer x) returns nothing integer array(32) binaryNumber integer i integer…
Q: Instruction: A mathematician named Ulam proposed generating a sequence of numbers from any positive…
A: Even number is found for when it is divided by 2 , and we get remainder 0 2) 8 (4…
Q: 0,1 Start SO OL= {0, 01, 01,01m | n.m>0} OL= {0, 01, 01nom | n,m>0} $1 0 1 $2 0,1
A:
Q: If f(n) is the number of times that y=y+A[i]; is executed in the code segment below, which of the…
A: Time complexity describes how much time a code takes to execute.
Q: Algorithm 4 procedure F4(n) s:=0 i:=n while i > 0 do t :=0 while t < i do s:=s+1 t:=t+1 i:=[i/2]…
A: Refer to step 2 for the answer.
Q: Given int n = (7-9/(3+4)*2-6%3); The value of n is: O a. 5 O b. 7 O c. 6 O d. 4 e. None
A: The answer is as follows:-
Q: Instruction: A mathematician named Ulam proposed generating a sequence of numbers from any positive…
A: - We have to code and make flowchart for the Ulam pattern.
Q: Fill the blank in the C program to find prime numbers between any two Intervals int n, n1, n2. k,…
A: According to the Question below the Solution:
Q: Below is C code and Python code for an algorithm. C code: 1: void foo( int n, int A, int B, int C )…
A: Answer:
Q: Instruction: A mathematician named Ulam proposed generating a sequence of numbers from any positive…
A: PROGRAM EXPLANATION Import the java.util package. Create the main class. Define the main method.…
Q: 6. What is printed by the following when executes? 1 str "His shirt is red" 2 pos= str.find("is") 3…
A: Answer the above question are as follows
Q: Q1: Write a program to compute a series (S) as below for n: 5 7 + + 25 47 9 n S = 1+3+ (n – 2)2
A: Algorithm: Step 1: Start the process Step 2: Declare integer variable n to store the nth term of…
Q: Give an algorithm that exchanges 2 memory units without extra memory
A: Consider two variables x and y. The algorithm to exchange these two variables without using extra…
Step by step
Solved in 2 steps with 2 images
- Use following series to do the given task; 135 79 11 13 15 1719 21 23 25 27 29 31 ... Given the number N of odd numbers in a certain line, your task is to determine the sum of the last three numbers of that line. For example N = 5 means, the third line, the last three numbers are 13, 15 and 17. The summation of these three numbers is 45. InputThe first line tells the number of test cases. From the next line, the input is a sequence of lines, one odd number N (1 < N <1000000000) per line. OutputFor each input line write the sum of the last three odd numbers written in that line of series with N numbers.Write a program that reads in three integers and prints “in order” if they are sorted in ascending or descending order, or “not in order” otherwise. For example, 1 2 5 in order 1 5 2 not in order 5 2 1 in order 1 2 2 in orderWrite a program to read A[n, n] of numbers, then put 10 instead each evenpositive number.
- In PYTHON, write a code that allows the user to input two non-negative number sequences in increasing order (the numbers entered are always getting bigger, and no number repeats), both terminated by a -1. The output of this code should be a third sequence that is a COMBINATION of both sequences 1 and 2 and is sorted in non-decreasing order where if there are two of the same number they are put together in the final sequence. Such as 1, 20.3, 20.3, 66, 7, 4 please do this using PYTHON, ONLY using while loops. NO language of "break", "len", "True", or "return" anywhere in the code! DO THIS USING 3 SEPARATE LISTS!In PYTHON, write a code that allows the user to input two non-negative number sequences in increasing order (the numbers entered are always getting bigger, and no number repeats), both terminated by a -1. The output of this code should be a third sequence that is a COMBINATION of both sequences 1 and 2 and is sorted in non-decreasing order where if there are two of the same number they are put together in the final sequence. Such as 1, 20.3, 20.3, 66, 7, 4 please do this using PYTHON, ONLY using while loops. NO language of "break", "len", "True", or "return" anywhere in the code! DO THIS USING 3 SEPARATE WHILE LOOPS!Start with any positive number n. If n is even divide it by 2, if n is odd multiply by 3 and add 1. Repeat until n becomes 1. The sequence that is generated is called a bumpy sequence. For example, the bumpy sequence that starts at n = 10 is: 10, 5, 16, 8, 4, 2, 1and the one that starts at 11 is11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 Write a function named lengthBumpy that returns the length of the bumpy sequence generated by its integer argument. The signature of the function is int lengthBumpy(int n) Examples:lengthBumpy(10) returns 7, and lengthBumpy(11) returns 15. You may assume that the argument n is positive and that the sequence converges to 1 without arithmetic overflow.
- Encryption is commonly used to disguise messages on the internet. A Caesar cipher performs a shift of all of the characters in a string (based on their ASCII values, see Table 1.2), e.g. h e l l o m j q q t The example shows a shift with a distance of 5 characters, i.e. h(ASCII:104) m(ASCII:109) Write a Python program that ask the user to input a line of plaintext and the distance value and outputs an encrypted text using a Caesar cipher, with the ASCII values range from 0 through 127. The program should work for any printable characters.A Fibonacci sequence is a sequence of numbers where each successivenumber is the sum of the previous two. The classic Fibonacci sequencebegins: 1, 1, 2, 3, 5, 8, 13, .... Write a program that computes the nthFibonacci number where n is a value input by the user. For example, ifn = 6, then the result is 8.Write this using java Write a complete version of the Bresenham Midpoint algorithm to handle ALL slope values. m = 0 m > 0 m < 0 m = 1 m > 1 swap the rolls of x and y m < 1 m = infinity ( needs special test case) Include appropriate tests for ‘special case’ conditions. Insteadof “WritePixel” write to the screen the coordinates of the pixel that would be drawn. Please provide photos that it works and so I can understand the code better
- IN STO a IN STO b test LDA a SUB b BRP count LDA c OUT LDA d OUT HLT count STO a LDA c ADD one STO c LDA d SUB b STO d BR test a DAT b DAT c DAT 0 one DAT 1 d DAT 0 Using this LMC program to solve a÷b=cRd where a = 20 b = 4 what is c and remainder d. IF a = 20 b = 4 c should be 5 and d should be 0. IS there reason to why i keep getting the remainder as 980Write an Algorithm that will read the student name and student id, the algorithm will Print the student name and student id, each in separate line. print the count of number of characters in student name (The space is calculated as character) Check the student ID last two digit, if last two digits are even numbers or odd numbers for the student ID which categorized as even, print the summation of odd number inside the student id, and print the count for the even number inside the entered student ID. The student ID which have an odd number in last two digit, print “the last two digits in student ID is odd numbers”. print the summation of even number inside the student id print the count for the odd numbers inside the enter student ID. Example Mohammed Ali Abdullah 1135728 Student Name: Mohammed Ali Abdullah Student ID: 1135728 number of characters: 21 The last two digits in student ID are even numbers The summation of odd numbers is 17 The count of odd numbers is 5Given two variables A and B, with integer values, write an algorithm that changes the values of the variables, without creating a new variable.ex: A = 3, B = 5 -> A = 5, b = 3)