As I see it: second variable 'num' in line 6 - is initialized with self assignment. It means assignments of a variable to itself.
So, it is redundant and should be removed as it doesn't have any effect and it is completely unnecessary.
It is frightful only at the very beginning. Then - you'll like it.
It is the sort of thing that might come up in exams; it is necessary for OP, if he hasn't forgotten he asked this question three weeks ago, to understand how the code works and what the value/s is/are at the end of a run of that method.
Of course, I have an idea what a hightly optimised version of that code might do
You didn't tell me he was so big. Unlike this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop