Boston numbers doubt

for finding out sum of prime factors of the number given ,
if i m running the for loop till sqrt(n) it is not being executed completely
cant figure out whats going wrong
wheres if i run the for loop till n the code works properly

https://ide.codingblocks.com/s/221851 here is the code

n tk chalao yr loop not all prime factors will be before sqrt n

in this one it is printing all prime nos ,running till sqrt(n)

@rohit_1906 you are running your code upto n ,change it to sqrt(n). After running your code till sqrt(n). If the value of n is greater than 1 add then number .

@rohit_1906 YOu can take a look for this code as a reference.