22
Code that replicates itself(not recursion)
The situation is similar with digital virus aka computer virus. If somehow just one virus can enter your computer, in right condition it will create millions of copies of itself.
So what is a computer virus? A computer is just some code that has the ability to replicate itself. Code that can output itself is called Quine.
However a code that simply just reads itself is not a Quine.
So what is a computer virus? A computer is just some code that has the ability to replicate itself. Code that can output itself is called Quine.
However a code that simply just reads itself is not a Quine.
#not a quine
print(open(__file__).read())
Code for a quine is made out of two parts:
Here's an example of quine in Python
q='q=%r;print (q%%q)';print (q%q)
#output: q='q=%r;print (q%%q)';print (q%q)
And in JS:
($=_=>`($=${$})()`)()
//output in console: ($=_=>`($=${$})()`)()
You can find more examples of quine by following these links: JavaScript Quines, Python Quines
That's all for now. Make sure you check out my other articles and YT tutorials.
22