السابق التالي
0 / 18
الوحدة النمطية DEMO-32-90DEMO-C-32

Primality Tester

DEMO-C-32 • Programming in C

Browser-only practice

بيان المشكلة

Write a function int isPrime(int n) that returns 1 if n is a prime number, and 0 otherwise.

A prime number is greater than 1 and has no divisors other than 1 and itself.

قيود

n

تنسيق الإدخال

A single integer.

تنسيق الإخراج

1 or 0.

حالات اختبار نموذجية

Submit runs every public testcase in this browser. Results and code never leave this device.

العينة رقم 1
عينة ظاهرة
2
1
2 is prime.
العينة رقم 2
عينة ظاهرة
4
0
4 is not prime.
العينة رقم 3
عينة ظاهرة
1
0
1 is not prime.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
إعدادات المحرر