Why Do AIs Pick 42 or 17? Random Numbers and Seed 42 Explained
Why AIs pick numbers such as 42 or 17, why random_state=42 appears in code, and why an LLM should not be treated as a random-number generator.
The short answer
The short answer is that LLMs behave as biased text generators rather than uniform random-number generators.
Research into LLM number generation found strong, repeatable preferences rather than genuinely random choices. The preferred answers varied by model, prompt language, temperature and number range. That means an AI may favour 42 or 17 without either number being a universal AI default.
Why do AIs pick 42?
Because 42 is culturally established as Adams's famous answer and the LLM study identifies it as a culturally salient exception, the number is more likely to appear than a uniform draw would suggest.
It is not a hidden preference or a mystical property of the model. It is a familiar pattern from human culture being reproduced in generated text.
Why do AIs sometimes pick 17 instead?
There is no single number that AIs always choose. The evidence shows that number preferences depend on the model, language, prompt, temperature and available range.
The same research found preferences for central values in small ranges and for numbers such as 37, 47 and 73 in larger ranges. It also connects these choices with human habits such as avoiding extremes and numbers that look too neat.
So 17 may appear frequently in a particular experiment, but the evidence does not establish it as the universal AI number.
Why LLM randomness is not uniform randomness
An LLM generates a response by selecting likely next tokens. It does not automatically perform a uniform draw from every valid integer in the range you specified.
Changing the temperature can change which numbers appear, but the observed preferences still vary with the model, language and range. More varied output is not the same thing as statistically uniform output.
This is why a prompt such as "pick a random number" can repeatedly produce familiar, human-looking answers. The model is imitating patterns associated with randomness rather than proving that every permitted number had an equal chance.
Why is random_state=42 so common?
This is a related convention, but it is not the same behaviour.
The scikit-learn glossary says that random_state controls the random-number generator used by an estimator or cross-validation splitter. Passing a fixed integer can make calls reproducible.
The glossary specifically names 0 and 42 as popular integer seeds and recommends checking stability across several distinct seeds. Seed 42 is therefore a convention, not a uniquely accurate or more random setting.
When an LLM answers 42, the result reflects learned token probabilities and cultural patterns. When code uses random_state=42, the number is an explicit seed chosen to make a randomised process reproducible.
What should you use instead?
- If you need a fair or uniform draw, do not rely on an LLM's unaided text response because LLM-generated numbers show systematic biases.
- If you need a reproducible machine-learning experiment, set an explicit integer seed and check the result across multiple distinct seeds.
- If you are testing model behaviour, vary the prompt, range, language and temperature because each can affect the preferred answer.
- Treat a different answer as variety, not proof of genuine randomness.
The wider lesson
The 42 habit is a neat example of how language models reproduce familiar human defaults. Similar issues appear when systems produce flattering or overly agreeable answers, explored in my article on agreeable AIs.
For practical habits around questioning model output rather than accepting it at face value, see how to keep your critical thinking sharp when using AI.
Bottom line
AIs do not always pick 42 or 17. They favour different numbers according to learned cultural patterns, prompt wording, model settings and the range offered.
The seed in random_state=42 serves a different purpose: it makes a randomised software process reproducible. In either case, 42 is familiar rather than magical.
Related
Keep reading
AI
AI cyberattacks are getting cheaper to launch - and harder to defend against
AI is not inventing cybercrime from scratch, but it is compressing the time and cost of attacks. UK organisations now need faster patching, clearer AI accountability and better control over automated tools.
JoshuaNovember 1, 2026
AI
AI NPCs That Talk Back in Real Time: What the NPCTalk Demo Means for Gaming
A new NPCTalk demo claims to give game NPCs real-time, in-character dialogue with cloned voices and sub-second responses. Here is what it means for developers, studios, and players.
JoshuaOctober 25, 2026
AI
How attacks on data centres can disrupt AI, cloud services and digital infrastructure
Recent disruption to Russian data centres shows why AI is not just software. It depends on physical facilities, power, cooling, networks and recovery planning.
JoshuaOctober 25, 2026
Tagged
Last updated
Category
aiLikes
Star Rating
No ratings yet
Comments
No comments yet - start the conversation.