# Check for prime numbers

```The IsPrime() function uses the recursive method to check if a number is prime. It's a fast function which can compute thousands of numbers within seconds.
```
``````<?php
// Checks for prime numbers
function IsPrime(\$Num)
{
\$No = 0;
for(\$CurrNum = 2; \$CurrNum <= \$Num; \$CurrNum++)
{
for(\$Divisor = 2; \$Divisor < \$CurrNum; \$Divisor++)
{
\$Res = \$CurrNum / \$Divisor;
if(\$Res != 1 && intval(\$Res) == \$Res)
{
\$No = 1;
\$Divisor = \$CurrNum;
}
}
if(\$No != 1)
{
\$Result = \$CurrNum;
}
\$No = 0;
}

// If the only divisor is the number itself, it's prime
if(\$Result == \$Num)
{
return 1;
}
else
{
return 0;
}
}

// Check for primes, 0 to 100
for(\$i = 0; \$i < 100; \$i++)
{
echo \$i." is a prime number? ".IsPrime(\$i)."<br />";
}
?>``````
##### Nathan
Nathan Pakovskie is an esteemed senior developer and educator in the tech community, best known for his contributions to Geekpedia.com. With a passion for coding and a knack for simplifying complex tech concepts, Nathan has authored several popular tutorials on C# programming, ranging from basic operations to advanced coding techniques. His articles, often characterized by clarity and precision, serve as invaluable resources for both novice and experienced programmers. Beyond his technical expertise, Nathan is an advocate for continuous learning and enjoys exploring emerging technologies in AI and software development. When he’s not coding or writing, Nathan engages in mentoring upcoming developers, emphasizing the importance of both technical skills and creative problem-solving in the ever-evolving world of technology. Specialties: C# Programming, Technical Writing, Software Development, AI Technologies, Educational Outreach