seems to work
This commit is contained in:
1 parent
8aa73bde5e
commit
2930b7217d
9 files changed
+280
-105
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
# lab 4
|
||||
|
||||
## ex 1
|
||||
|
||||
In this problem, we would like to implement the algorithm to calculate the digit sum of a given natural number that can be used in detecting errors in message transmission or data storage.
|
||||
For example:
|
||||
N = 103509, the digit sum = 1 + 0 + 3 + 5 + 0 + 9 = 18.
|
||||
N = 9512, the digit sum = 9 + 5 + 1 + 2 = 17
|
||||
|
||||
- Write a pseudo-code to solve the above problem using Iteration.
|
||||
- Write a program from the pseudo-code and solve the Problem using Iteration.
|
||||
- Calculate the complexity. Justify your answer.
|
||||
- Write a program to solve the Problem using Recursion (with Iteration if necessary).
|
||||
- Calculate the complexity. Justify your answer.
|
||||
|
||||
## exercise 2
|
||||
|
||||
Write a program in C/C++ to enter a natural number n and find all sphenic numbers from 1 to n using Recursion. Calculate the complexity of the proposed algorithm.
|
||||
|
||||
Note: A sphenic number is a product of $p \times q \times r$ where p, q, and r are three distinct prime numbers.
|
||||
Example: $30 = 2 \times 3 \times 5$; $42 = 2 \times 3 \times 7$; $66 = 2 \times 3 \times 11$
|
||||
Reference in new issue
Block a user