B C++
#include "stdafx.h"
#include "iostream"
using namespace std;
main()
{ int d,k,n,i,s=6;
cout<<"vvedite n \n";<br> cin>>n;
cout<<1<<endl<<2<<endl<<3<<endl;<br> k=5;
while (k<=n)<br> { for (d=2;d*d<=k && k%d!=0;d++)<br> ;
if(d*d>k)
cout<<k<<endl;<br> s=k+s;
k=k+2;
}
cout<<"summa="<<s;<br> getchar();
getchar();
return 0;
}