Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7. An integer is called a prime number if a natural number that has exactly two distinct natural number divisors: 1 and itself. For example,

7. An integer is called a prime number if a natural number that has exactly two distinct natural number divisors: 1 and itself. For example, 2, 3, 5, 7, 11, 13 are prime numbers. Write a recursive function called isPrime to determine whether an integer is a prime number. The recursive function isPrime has two parameters: the first one is the test number p and the second one is a divisor q which is greater or equal to 2 and less than p. The function will return 1 if p=q (it is better if (q*q>p), why?) and return 0 if p%q = 0 (note that, in this case, remainder is 0 and p>q). Those two cases are base cases. Then recursively call isPrime(p, q+1). In your main function, prompt user to input a positive number then call the recursive function isPrime(p,2). If the function return 1, output The number XX (the input number) is a prime number, otherwise, The number XX is not a prime number. 8. Write a program that generates an abridged version of a multiplication table. Use a double-subscripted array to represent your table. All multiplications from 1 to 9 should be included (i.e., 9*9=81 is largest value in the table). Initialize your array to 0 and have your program populate the array with the proper values. That is, you can assign the value of the (i+1)th row and (j+1)th column to i*j, i.e., a[6][9] = 54. You dont need to output any data.

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

Step: 3

blur-text-image

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

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

What is the first step in analyzing a statute?

Answered: 1 week ago

Question

d. Who are important leaders and heroes of the group?

Answered: 1 week ago