Hello i want to write a program which find the biggest prime factor of a number for example the biggest prime factor of six is three or the biggest prime factor of fifteen is five

This is my Code please tell me what is my program bug

Code:#include <stdio.h> // main functions #include <math.h> // for sqrt function int main() { int i, j, k, f; // F = Flag; printf("Enter K\n\n"); // The Number which we want to scan scanf("%d", &k); // Scanning Number for (i = 2; i < k; i++) // loop for factors { if (k % i == 0) { for (j = 1; j < sqrt(i); j++) //prime loop if (i % j == 0) { printf("%d\n\n", i); } } } return 0; //Check if the program has work correctly & Finish }