Purchase Solution

An Iterative GCD Program and Testing in C

Not what you're looking for?

Ask Custom Question

Write program to test function then write and test an equivalent iterative function
int gcd (int a, int b)
{
int r;
if ((r=a%b)==0)
return b
else
return gcd(b,r);
}

Purchase this Solution

Solution Summary

The solution is a C program to test a given (recursive) GCD function, then implements and test an equivalent iterative GCD function

Solution Preview

The following program has been done:

//////////////////////////////////////////////////////////////////////////
// gcd.c
// function to calculate greatest common divisor (gcd) Iteratively
//
// author: Abdun Mahmood
// date : 13.09.2006
//////////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include <stdlib.h>

// Signature of gcd-functions
int gcdRec(int a, int b);
int gcdIt(int a, int b);

// main ...

Purchase this Solution


Free BrainMass Quizzes
Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Javscript Basics

Quiz on basics of javascript programming language.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.