#include <iostream>
using namespace std;
int main() {
int n;
cout<<"enter a number: ";
cin>>n;
cout<<endl;
int i;
int f;
f=1; // storing the number
for (i=1 ; i<=n/2 ; i++){
if (n%i==0)
f = i; // storing the largest factor
}
cout<<"the largest factor of "<<n<<" is "<<f;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: