➤ Problem Link : AFS
👉 Hint : edit please
✅ C++ Solution :
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ans[1000001],f[1000001];
int main()
{
    	int n=1000000;
		ans[0]=0;
		ans[1]=0;
		f[0]=0;
		f[1]=0;
		for(int i=0;i<=n;i++)
			f[i]=1;
		for(int i=2;i<=n;i++)					
		{
			for(int j=i*2;j<=n;j+=i)
			{
				f[j]+=i;
			}
		}
		
		
		
		
		int t;
		for(int i=2;i<=n;i++)
		{
			
			ans[i]=ans[i-1]+f[i];
		}
	int st;
	cin>>st;
	while(st--)
	{
        int s;
        cin>>s;
		cout<<ans[s]<<"\n";
	}
}
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!
