Write your question here.
I made a function for c++ and my professor said I cannot use sqrt(n) in my function. I have no clue how to make this function without using sqrt(n).
how about n/2? :) It would simply mean it does some unnecessary computation... it's less efficient, but you will not be using sqrt.
What's the reason he's not allowing you to use sqrt?
On the other hand one thing that pops into my mind now is maybe your professor is asking you to implement the sieve of Eratosthenes?
@Aceix
I'm so dumb and newby.... I cannot really understand your code
well now there is one more bigger problem that I faced
I just contacted the professor, she said I cannot use for. Now, her class doesn't really make sense for me. she want me to use while, but for is shorter than while isn't it?
1 2 3 4 5 6 7 8
for(i=2;i<=d;i++)
{
if(n%i==0)
{
f=1;
i=i+d;
}
1 2 3 4 5 6 7 8 9
int i = 1;
while (i <=d){
i = i + 1
{
if(n%i==0)
{
f=1;
i=i+d;
}
so now i'm working with change all for loop to while
Like I said in the other thread this is why you should write your own code and not use your friends code...She probably only wants you to use what you have learned in class so far. As far as the sieve of eratosthenes I told you what it was the other day :P http://www.cplusplus.com/forum/beginner/125481/#msg680556
@giblit
I wanted to do it by myself if I know how to do it.
All of my classmates don't know how to do it she basically teach 2 + 2 and want us to do 2 * 5 that's why I failed to do it by myself. I was doing it for 5 hours and I asked the professor several times and she doesn't help me and keep saying "you cannot use this, think" she kept said "think" and never gave me a single help. I am ashamed to get my friend to do it for me. I really want to do it by myself and that's why I joined cplusplus But thank you for your advise