Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write and test a Pep/9 translation of the following C program. Collatz' conjecture is that if the following operation is applied repeatedly to a positive

write and test a Pep/9 translation of the following C program.

image text in transcribed

image text in transcribed

Collatz' conjecture is that if the following operation is applied repeatedly to a positive integer (N) it will eventually reach 1 If N is even, N N/2 otherwise N-N 3+1 For example, if we start with 7, we reach 1 in 16 steps 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 Write and test a Pep/9 translation of the following C program. Note that variable number is unsigned so has range 0.65535. The usage of number is highlighted #include int main ) int N, count unsigned number; scanf ("%d%, &N) ; while (N0) number N count-0; while (number-1) if (number%2 0 ) number = number / 2; else number number 31: count ++ printf("%d steps ", count); scanf ("%d", &N) ; printf ("Goodbye ") Your program should check for overflow where appropriate You can check your results at http://www.nitrxgen.net/collatz/ If you would like to output intermediate values as they are calculated, you can use the udeco subroutine available on the course home page. It prints a 16-bit unsigned number in decimal Collatz' conjecture is that if the following operation is applied repeatedly to a positive integer (N) it will eventually reach 1 If N is even, N N/2 otherwise N-N 3+1 For example, if we start with 7, we reach 1 in 16 steps 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 Write and test a Pep/9 translation of the following C program. Note that variable number is unsigned so has range 0.65535. The usage of number is highlighted #include int main ) int N, count unsigned number; scanf ("%d%, &N) ; while (N0) number N count-0; while (number-1) if (number%2 0 ) number = number / 2; else number number 31: count ++ printf("%d steps ", count); scanf ("%d", &N) ; printf ("Goodbye ") Your program should check for overflow where appropriate You can check your results at http://www.nitrxgen.net/collatz/ If you would like to output intermediate values as they are calculated, you can use the udeco subroutine available on the course home page. It prints a 16-bit unsigned number in decimal

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

Students also viewed these Databases questions

Question

Global sourcing as a potential sourcing strategy.

Answered: 1 week ago

Question

Explain how to build high-performance service delivery teams.

Answered: 1 week ago

Question

Understand what a service-oriented culture is.

Answered: 1 week ago