是素数吗?
Coddy 数学谜题 课程的第 6 课,共 20 课。
挑战
简单编写一个函数 isPrime,判断给定的数字 <i>x</i> 是否为质数?
函数会返回一个布尔值,True 或 False。
亲手试试
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "solution.h"
int main() {
int n;
if (scanf("%d", &n) != 1) n = 0;
bool r = isPrime(n);
printf("%s\n", r ? "true" : "false");
return 0;
}
数学谜题中的所有课
自己练习: C 在线编译器