Em moi cai Ubuntu nen ko the type tieng Viet dc, mong moi nguoi thong cam.
Em co’ thu? build 1 chuong trinh C bang terminal thi gap error nhu sau:
/tmp/ccqu41wG.o: In function `CheckPrimeNumber':
helloworld.c:(.text+0x5e): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
Con day la` source code (em code tren gedit)
#include <stdio.h>
#include <math.h>
#define bool _Bool
#define true 1
#define false 0
bool CheckPrimeNumber(int n)
{
if (n < 2)
return false;
else if (n == 2)
return true;
else if (n & 0)
return false;
else {
for (int i = 3; i <= sqrt(n); i += 2) {
if (n % i == 0)
return false;
}
return true;
}
}
int main()
{
int number = 7909;
if (CheckPrimeNumber(number))
printf("This is a prime number.\n");
else
printf("This is not a prime number.\n");
return 0;
}
Giup em nhe’, cam on moi nguoi