Presentation exercise 6 Write a function called num_of_digits which takes as input an integer and returns the number of digits in input number. For example, num_of_digits (6539) returns 4. Note that the input integer is not necessarily a positive number. Using this function, write another function (including docstring) called curious which takes as input an integer and returns true if the input represents a curious number, false otherwise. An n digit number is said to be curious if the last n digits of its square are equal to the original number. For example, curious (25) returns True, since 25 contains two digits and the last two digits of its square (625) are equal to 25.
Presentation exercise 6 Write a function called num_of_digits which takes as input an integer and returns the number of digits in input number. For example, num_of_digits (6539) returns 4. Note that the input integer is not necessarily a positive number. Using this function, write another function (including docstring) called curious which takes as input an integer and returns true if the input represents a curious number, false otherwise. An n digit number is said to be curious if the last n digits of its square are equal to the original number. For example, curious (25) returns True, since 25 contains two digits and the last two digits of its square (625) are equal to 25.
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section: Chapter Questions
Problem 4PP
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning