Elkanah modi's Profile
Reputation: 0
Apprentice
- Group:
- Members
- Active Posts:
- 16 (0.06 per day)
- Joined:
- 15-August 12
- Profile Views:
- 860
- Last Active:
Sep 05 2012 12:05 AM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
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.. -
In Topic: fibonacci series
Posted 23 Aug 2012
mostyfriedman, on 22 August 2012 - 11:38 PM, said:I don't understand your question, can you please clarify?
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.... -
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... -
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++; } } -
In Topic: to find the largest palindrome number 2-digit
Posted 16 Aug 2012
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Click here to e-mail me
Friends
|
|


Find Topics
Find Posts
View Reputation Given

|
Comments
Elkanah modi has no profile comments yet. Why not say hello?