Question

Write a Turing program that computes addition of natural numbers. What do you need to define...

Write a Turing program that computes addition of natural numbers. What do you need to define first?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer Part 1 :

var x : real

var y : real

put " Enter the Range of natural numbers for calculating sum

put "Enter first natural number "

get x

put "Enter last natural number"

get y

var i : real

i =0

for count : x .. (y+1)

i=i+x

end for

put "The sum of natural number ranging from", x, "and", y, "is", i

Answer Part 2 : we need to define firstly the variables which we use in our solutions and then we will run for loop under which we are summing up the numbers between the range

Add a comment
Know the answer?
Add Answer to:
Write a Turing program that computes addition of natural numbers. What do you need to define...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What to do Write a C program that computes Pi with the approximation algorithm that I...

    What to do Write a C program that computes Pi with the approximation algorithm that I introduced in class. I want you to write the program in two different ways: The first version will add up the first 28284277 elements of the approximation series in a simple for loop. I ask you to put the code into a function with this signature: float get_pi_for(void); The second version will break out of a while loop depending on whether a pair of...

  • Need help figuring this out Write a program that reads in a sequence of numbers (doubles)...

    Need help figuring this out Write a program that reads in a sequence of numbers (doubles) from standard input until 0 is read, and stores them in an array, This part is done using iteration (loop). You may assume that the maximum size of the array will not be more than 100. Your program computes the maximum number stored in the array, the count of negative numbers, and computes the sum of positive numbers, using recursion. You need to have...

  • A=[-6,8,2;1,-3,20;15,-10,5]; Write a program that computes the array B by computing the natural logarithm of all...

    A=[-6,8,2;1,-3,20;15,-10,5]; Write a program that computes the array B by computing the natural logarithm of all the elements of A whose value is greater than or equal to 1. Otherwise add 30 to each element that is less than 1. Do this in two way. A) By using a for loop with conditional statements B)By using a logical array as a mask MATLAB CODE

  • Write a TM (Turing Machine) program that adds two base two numbers. Input is two nonnegative inte...

    Write a TM (Turing Machine) program that adds two base two numbers. Input is two nonnegative integers in base 2 with a plus sign between them. Output is their sum in base 2, with nothing else left on the tape. So first decrement, then increment. Use an online Turing Machine Simulator to see how it works. Use the following language for the program: current state, read symbol, next state, write symbol, direction [directions are (< left, > right, s stay)]...

  • This is a turing prgram that I need help on. How does this turing program/algorithm give...

    This is a turing prgram that I need help on. How does this turing program/algorithm give me f(x)=2x, in other words, what is happening? If you also can, can you connect to the URM porgram and the differences in what it's doing?

  • In C# write a program for factorizing natural numbers and computing GCF & LCM of two...

    In C# write a program for factorizing natural numbers and computing GCF & LCM of two natural numbers. Users must be promoted to enter two numbers. use class List<>to represent factorizations. Sample Program: Enter first num: 36    Enter second num: 48 Factor of 36 are: 2 2 3 3 Factor of 48 are: 2 2 2 2 3 common factors of 36 & 48 are: 2 2 3 GCF of 36 and 48 is: 12 LCM of 36 and...

  • c++ program Write a recursive function that computes and returns the product of the first n...

    c++ program Write a recursive function that computes and returns the product of the first n >=1 real numbers in an array.

  • please show the code in java,thanks 5. Perfect Numbers Version 2: Write a program which computes...

    please show the code in java,thanks 5. Perfect Numbers Version 2: Write a program which computes perfect numbers according the following algorithm: for each prime, p: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 if 2P 1 s prime (2P (2 is perfect: print both p and (2P 1)(2) Note: You will need to use the Biglnteger clas for thist

  • Using the MARIE computer assembly language, write a program that computes the following expression: z ß...

    Using the MARIE computer assembly language, write a program that computes the following expression: z ß (a * b) * (c * d). The computer will read in the input values a, b, c, and d from the keyboard, and the final result (z) has to be displayed. In addition, every time an input value is read in, it must be displayed on the screen. Each time a multiplication of two numbers is needed, it has to be done using...

  • In C++, Write a program that it prompts to user for two integers, computes the quotient...

    In C++, Write a program that it prompts to user for two integers, computes the quotient of two integers, and then displays the result. You need to do the following things in this assignment: + The main function prompts for user input and reads the two integers that the user entered. + Write a quotient function that computes the quotient of two integers and return the results. (hint: avoid integer division and divide by zero)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT