Natural numbers are the counting numbers. On this page we use the school-friendly rule: an integer is natural when n > 0 (that is, 1, 2, 3, …).
Remember
n is natural ⇔ n is an integer and n > 0
Examples:
1 → natural
42 → natural
0 → not natural (this page)
-3 → not natural
Note: some syllabi include 0. Always state your definition.
n
Check
Result
5
5 > 0
Natural
1
1 > 0
Natural
0
0 > 0 is false
Not natural
-2
-2 > 0 is false
Not natural
Approach
How to Check a Natural Number in JavaScript
Three clear steps — then either classify one value or list a range.
State the definition you will use (here: n > 0).
Compare the integer against zero and return a boolean.
Optionally loop from 1 to N to print natural numbers in a range.
Task
Idea
Time
Best for
Single check
return n > 0;
O(1)
Yes/no classification
Range print
Loop i from 1 to N
O(N)
Listing counting numbers
Pseudocode
Pseudocode
function IsNatural(n):
return n > 0
function PrintNaturals(limit):
for i from 1 to limit:
print i
Reference
Cheat Sheet
Keep these facts handy while writing the program.
Topic
Detail
This page rule
n > 0
Alternate rule
n >= 0 (includes zero)
Set
{1, 2, 3, …}
Zero
Not natural here — say so in interviews
Negatives
Never natural under either common rule
Helper tip
Return a boolean; let the caller print the message
Try it
Live Preview
Enter any integer to see whether it is natural under n > 0.
Whole numbers only. Tap a chip or type a value.
Result
n = 5
Check: 5 > 0 → true
Verdict: NATURAL NUMBER
Code
JavaScript Programs
Start with a boolean helper for one value. Then print natural numbers from 1 to 10 with a simple loop.
Example 1 — Single Check
Return true when the integer is greater than zero.
JavaScript
function isNatural(n) {
return n > 0;
}
const number = 5;
if (isNatural(number)) {
console.log(number + " is a Natural Number.");
} else {
console.log(number + " is not a Natural Number.");
}