5. Find all positive integers $n$ such that $\varphi(n)=24$.

The Euler's totient function $\varphi(n)$ counts the number of positive integers up to $n$ that are relatively prime to $n$. We need to find all $n$ for which $\varphi(n) = 24$.

To solve this, we can use the formula for the Euler's totient function:
\[
\varphi(n) = n \prod_{p \mid n} \left(1 - \frac{1}{p}\right),
\]
where the product is over all distinct prime factors $p$ of $n$.

Let's consider the possible forms of $n$:

1. **Case 1: $n$ is a prime power $p^k$**
   \[
   \varphi(p^k) = p^k - p^{k-1} = p^{k-1}(p-1).
   \]
   Setting this equal to 24, we get:
   \[
   p^{k-1}(p-1) = 24.
   \]
   We need to find prime $p$ and integer $k$ such that this equation holds. Checking small primes:
   - For $p = 2$, $2^{k-1}(2-1) = 2^{k-1} = 24 \Rightarrow k-1 = 4 \Rightarrow k = 5$. Thus, $n = 2^5 = 32$.
   - For $p = 3$, $3^{k-1}(3-1) = 3^{k-1} \cdot 2 = 24 \Rightarrow 3^{k-1} = 12 \Rightarrow k-1 = 2 \Rightarrow k = 3$. Thus, $n = 3^3 = 27$.
   - For $p = 5$, $5^{k-1}(5-1) = 5^{k-1} \cdot 4 = 24 \Rightarrow 5^{k-1} = 6 \Rightarrow k-1 = 1 \Rightarrow k = 2$. Thus, $n = 5^2 = 25$.
   - For $p = 7$, $7^{k-1}(7-1) = 7^{k-1} \cdot 6 = 24 \Rightarrow 7^{k-1} = 4 \Rightarrow k-1 = 1 \Rightarrow k = 2$. Thus, $n = 7^2 = 49$.
   - For $p = 13$, $13^{k-1}(13-1) = 13^{k-1} \cdot 12 = 24 \Rightarrow 13^{k-1} = 2 \Rightarrow k-1 = 1 \Rightarrow k = 2$. Thus, $n = 13^2 = 169$.

2. **Case 2: $n$ is a product of two distinct primes $p$ and $q$**
   \[
   \varphi(pq) = (p-1)(q-1).
   \]
   Setting this equal to 24, we get:
   \[
   (p-1)(q-1) = 24.
   \]
   We need to find pairs of primes $(p, q)$ such that this equation holds. Checking pairs:
   - For $(p-1, q-1) = (1, 24)$, $(p, q) = (2, 25)$, but 25 is not prime.
   - For $(p-1, q-1) = (2, 12)$, $(p, q) = (3, 13)$, both are prime. Thus, $n = 3 \cdot 13 = 39$.
   - For $(p-1, q-1) = (3, 8)$, $(p, q) = (4, 9)$, but 4 and 9 are not prime.
   - For $(p-1, q-1) = (4, 6)$, $(p, q) = (5, 7)$, both are prime. Thus, $n = 5 \cdot 7 = 35$.
   - For $(p-1, q-1) = (6, 4)$, $(p, q) = (7, 5)$, both are prime. Thus, $n = 7 \cdot 5 = 35$ (already found).
   - For $(p-1, q-1) = (8, 3)$, $(p, q) = (9, 4)$, but 9 and 4 are not prime.
   - For $(p-1, q-1) = (12, 2)$, $(p, q) = (13, 3)$, both are prime. Thus, $n = 13 \cdot 3 = 39$ (already found).
   - For $(p-1, q-1) = (24, 1)$, $(p, q) = (25, 2)$, but 25 is not prime.

3. **Case 3: $n$ is a product of three distinct primes $p$, $q$, and $r$**
   \[
   \varphi(pqr) = (p-1)(q-1)(r-1).
   \]
   Setting this equal to 24, we get:
   \[
   (p-1)(q-1)(r-1) = 24.
   \]
   We need to find triples of primes $(p, q, r)$ such that this equation holds. Checking triples:
   - For $(p-1, q-1, r-1) = (1, 2, 12)$, $(p, q, r) = (2, 3, 13)$, all are prime. Thus, $n = 2 \cdot 3 \cdot 13 = 78$.
   - For $(p-1, q-1, r-1) = (1, 3, 8)$, $(p, q, r) = (2, 4, 9)$, but 4 and 9 are not prime.
   - For $(p-1, q-1, r-1) = (1, 4, 6)$, $(p, q, r) = (2, 5, 7)$, all are prime. Thus, $n = 2 \cdot 5 \cdot 7 = 70$.
   - For $(p-1, q-1, r-1) = (2, 3, 4)$, $(p, q, r) = (3, 4, 5)$, but 4 is not prime.

Combining all the valid solutions, we get:
\[
n = 32, 27, 25, 49, 169, 39, 35, 78, 70.
\]

Thus, the positive integers $n$ such that $\varphi(n) = 24$ are:
\[
\boxed{32, 27, 25, 49, 169, 39, 35, 78, 70}.
\]
5. When $\varphi(n)=24$, $n$ can only have $2,3,5,7,13$ as its prime factors. Let $n=2^{a_{1}} 3^{a_{2}} 5^{a_{3}} 7^{a_{4}}$ $13^{a_{5}}$, we can calculate: $n=13 \cdot 3,13 \cdot 3 \cdot 2,13 \cdot 2^{2}, 7 \cdot 5,7 \cdot 5 \cdot 2,7 \cdot 3 \cdot 2^{2}, 7 \cdot 2^{3}, 5 \cdot$ $3^{2}, 5 \cdot 3^{2} \cdot 2,3^{2} \cdot 2^{3}$