## Elkanah modi's Profile User Rating:

Reputation: 0 Apprentice
Group:
Members
Active Posts:
17 (0.04 per day)
Joined:
15-August 12
Profile Views:
2,091
Last Active:
Aug 28 2013 06:52 PM
Currently:
Offline

### Previous Fields

Dream Kudos:
0
Elkanah modi has not set their status

1. #### In Topic: fibonacci series

Posted 30 Aug 2012

Skydiver, on 23 August 2012 - 09:58 AM, said:

The question posed by mostyfriedman was why not just loop from 0 to 1 million so that your are looping the same number of times and not having same odd construction the for loop?

The value of i never plays a part in your computation within your for loop other then the number of times the computation is done.

The code you have in the original post has i ranging from 3 million to 4 million meaning that you are looping 1 million times. You could have also made i range from 5 million to 6 million, or 7.5 million to 8.5 million and still get the same number of iterations.

Elkanah modi, on 23 August 2012 - 05:46 AM, said:

ok..for you i ll starts from 1...to 4 million bt am getting the same result....i was doing this for some reason..to check..my answer....

If you change the loop as you describe to go from 1 to 4 million, then now you are changing the number of iteration. Now you'll have 4 million iterations where as before you were only iterating 1 million times.

actually..istarted 4rm 1 to 10^6,,but was nt getting the answer,,so i tried it 3 to 4 (10^6),just as a trial...anyway..how can i modify it, so that it does nt overflow...and get the correct answers..
2. #### In Topic: fibonacci series

Posted 23 Aug 2012

mostyfriedman, on 22 August 2012 - 11:38 PM, said:

also why aren't you just iterating a 10^6-1 from 1 to 10^6, what's the reason for starting from 3 million and ending at 4 million

ok..for you i ll starts from 1...to 4 million bt am getting the same result....i was doing this for some reason..to check..my answer....
3. #### In Topic: To Find Prime Number Between Two Given Numbers

Posted 22 Aug 2012

sepp2k, on 22 August 2012 - 11:28 PM, said:

Allocating an array of that size on the stack will almost certainly exceed your platform's stack size limit. You should allocate it on the heap instead.

Note that on most (all?) platforms exceeding the allowed heap size won't cause an error until you actually try to access the parts of the memory that exceed the stack boundary. That's why you don't get an error for small inputs.

PS: What does this have to do with the Fibonacci series?

sorry..how can you give me some example..of what you are trying to explaining me..becoz i dont know how to allocate in heap...
4. #### In Topic: To Find Prime Number Between Two Given Numbers

Posted 22 Aug 2012

here it show me run time error for high value integers.......
```#include <iostream>
#define lim 100000
using namespace std;
int main()
{
unsigned long long int x,i,p,j,n,q;
int t = 1;
bool a[lim];
a[1] = false;
cin >> x;
while (t <= x) {
cin >> p;
cin >> q;
for (i = 2; i <= q; i++) {
a[i] = true;
}
for (i = 2; i <= q; i++) {
if (a[i] == true) {
for ( n = 0; n <= q; n++) {
j = i * i + n * i;
if (j > q)
break;
else
a[j] = false;
}
}
}
for (i = p; i <= q; i++) {
if (a[i] == true)
cout <<i << endl;
}
cout << endl;
t++;
}
}

```
5. #### In Topic: to find the largest palindrome number 2-digit

Posted 16 Aug 2012

goodsir, on 15 August 2012 - 08:49 PM, said:

Rather than keeping a max, wouldn't it be easier to count down in the for loops and break when you find a palindrome?

i have tried..bt its giving me some problem...so i did like this any way..thans...

Member Title:
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

E-mail: