Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Find the first number that matches a certain requirement
ResourceFunction["FindFirstNumberInstance"][f] finds the first integer instance from the range 1 to ∞ for which f returns True | |
ResourceFunction["FindFirstNumberInstance"][f,max] finds the first integer instance from the range 1 to max for which f returns True | |
ResourceFunction["FindFirstNumberInstance"][f,{min, max}] finds the first integer instance from the range min to max for which f returns True | |
ResourceFunction["FindFirstNumberInstance"][f,{min,max,step}] finds the first instance from the range min to max in steps of step for which f returns True | |
ResourceFunction["FindFirstNumberInstance"][f,spec, n] finds the first n instances for which f returns True |
Find the first prime starting from 1:
In[1]:= | ![]() |
Out[1]= | ![]() |
Find the first 10 composite numbers:
In[2]:= | ![]() |
Out[2]= | ![]() |
Find the first 15 square numbers that are a multiple of 7:
In[3]:= | ![]() |
Out[3]= | ![]() |
Find the first 15 palindromic primes:
In[4]:= | ![]() |
Out[4]= | ![]() |
Find the first 12 palindromes that are a multiple of 3:
In[5]:= | ![]() |
Out[5]= | ![]() |
Use an iterator with Real step size:
In[6]:= | ![]() |
Out[6]= | ![]() |
The iterator can not only be numbers, it can also be a symbolic expression:
In[7]:= | ![]() |
Out[7]= | ![]() |
FindFirstInstance will return less instances if no more instances exist:
In[8]:= | ![]() |
Out[8]= | ![]() |
For the case that there is no third argument and there is no match, FindFirstNumberInstance returns Missing:
In[9]:= | ![]() |
Out[9]= | ![]() |
An empty list is returned if there is a third argument:
In[10]:= | ![]() |
Out[10]= | ![]() |
Find the first 12 palindromic composites that are a multiple of 7:
In[11]:= | ![]() |
Out[11]= | ![]() |
Find the first 20 emirp primes:
In[12]:= | ![]() |
Out[12]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License