Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this question has to do with programming programming language: c++ Non-Assessed Task 3: Does a Factorial Divide? Advanced For this task, we want to know

this question has to do with programming
programming language: c++
image text in transcribed
Non-Assessed Task 3: Does a Factorial Divide? Advanced For this task, we want to know whether the factorial of an integer n can be divided by another integer m. (Put mathematically, The factorial for a non-negative integer n,n!, is defined as: 0!=1n!=n(n1)!(n>0). Moreover, m divides n! if there exists an integer k such that km=n!.) The input to your program will be two non-negative integers, n and m. (NB, make sure these inputs are reasonably sensible. Factorials get enormous fast. See below.) For each input, output a line stating whether or not n ! divides by m. Examples of input: 66202092710000100000 Examples of output: YES. 6! divides by 9. NO. 6 ! does not divide by 27. YES. 20! divides by 10000. NO. 20! does not divide by 100000 . Hints: - As with all the other tasks this week, you can implement this in Python or C++, or both. - A factorial is the product of all positive integers less than or equal to n. For example 5!=54321=120. For example 20!=2019181716151413121110987654321= 2432902008176640000. Yes, factorials get big fast! So one part of your code should work out the factorial of n, your first input. You may remember doing this on 4000CEM. That can be done iteratively or recursively. - Then another part of your code should work out whether the factorial of n can be divided by m. Remember that the result of n!/m has to be an integer, not a float. This is what needs checking. That can be done in one of two ways: by identifying whether (1) the result is an integer; or (2) whether the result has a remainder. If there is a remainder, then n cannot be divided by m. - You have to build a string to print as output

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

Real Time Database Systems Architecture And Techniques

Authors: Kam-Yiu Lam ,Tei-Wei Kuo

1st Edition

1475784023, 978-1475784022

More Books

Students also viewed these Databases questions