|
|
|
#261 |
|
Beyond the Code
Last Online: 06-15-2014
Join Date: Sep 2008
Posts: 2,993
Thanks: 2,214
Thanked 3,426 Times in 1,499 Posts
Groans: 57
Groaned at 69 Times in 52 Posts
|
Thanks Google
![]() EDIT: Show us how did u solve it
__________________
Whatever you do, do it for the Lulz. Last edited by Neoxter; 01-31-2010 at 09:30 PM. |
|
|
|
|
|
#262 |
|
Last Online: 12-20-2021
Join Date: Mar 2006
Posts: 6,245
Thanks: 2,121
Thanked 3,365 Times in 1,740 Posts
Groans: 29
Groaned at 44 Times in 35 Posts
|
Code:
#include <iostream>
using namespace std;
bool f(float);
int main(){
long i;
float a;
for(i = 0; i < 10000; i++){
a = (float)i;
if(f(a/6) && f(a/7) && f(a/8) && f(a/9) && f(a/10))
cout << "I = " << i << endl;
}
}
bool f(float a){
int b = a;
return (a==b);
}
__________________
What we do in life, echoes in eternity.
|
|
|
|
|
|
#263 |
|
Super Moderator
Last Online: 02-16-2022
Join Date: May 2006
Posts: 5,580
Thanks: 1,888
Thanked 2,653 Times in 1,593 Posts
Groans: 55
Groaned at 35 Times in 32 Posts
|
don't you dare to question my IQ and claim that i used google.
to form 2,4,8 you need (2,2,2) to form a 9 u need (3,3) to form a 7 you need a (7) to form a 5 you need a (5) to form a 6 u need nothing because you already have 3 and 2 to form a 10 u need nothing because you already have 5 and 2 you don't need a 1 do you so the answer is 2*2*2*3*3*5*7
__________________
click on 'Groan' to switch to my left testicle. |
|
|
|
| The Following User Says Thank You to Kingroudy For This Useful Post: | Neoxter (01-31-2010) |
|
|
#264 |
|
Last Online: 12-20-2021
Join Date: Mar 2006
Posts: 6,245
Thanks: 2,121
Thanked 3,365 Times in 1,740 Posts
Groans: 29
Groaned at 44 Times in 35 Posts
|
Code:
#include <iostream>
using namespace std;
bool f(float);
int main(){
long i;
int max;
bool display;
cout << "The number should be divisible by all digits from 1 to ";
cin >> max;
for(i = 1; i < 100000000; i++){
display = true;
for(int j = 1; j <= max; j++){
if(!f((float)i/j))
display = false;
}
if(display){
cout << "I = " << i << endl;
break;
}
else
cout << i << "\x8\x8\x8\x8\x8\x8";
}
if(display)
cout << "Done!" << endl;
else
cout << "Failed!" << endl;
return 0;
}
bool f(float a){
int b = a;
return (a==b);
}
Compile this one ![]() Note: the execution might be very slow if you use a large number.
__________________
What we do in life, echoes in eternity.
|
|
|
|
| The Following User Says Thank You to Tawa For This Useful Post: | Neoxter (01-31-2010) |
|
|
#265 |
|
Last Online: 05-30-2013
Join Date: Jan 2008
Posts: 1,788
Thanks: 10,018
Thanked 1,100 Times in 651 Posts
Groans: 1
Groaned at 6 Times in 6 Posts
|
@Tawa, your algorithm can be enhanced.
Instead of calling the stupid "f" function I don't know how much times, you could just use the modulus operator like this: if(i%j != 0) instead of: if(!f((float)i/j)) As for the "Decore", no need for "\x8\x8\x8\x8\x8\x8", \r will do the job.
__________________
|
|
|
|
| The Following User Says Thank You to Google For This Useful Post: | Tawa (02-02-2010) |
|
|
#266 | |
|
Last Online: 05-30-2013
Join Date: Jan 2008
Posts: 1,788
Thanks: 10,018
Thanked 1,100 Times in 651 Posts
Groans: 1
Groaned at 6 Times in 6 Posts
|
Quote:
__________________
|
|
|
|
|
|
|
#267 | |
|
Super Moderator
Last Online: 02-16-2022
Join Date: May 2006
Posts: 5,580
Thanks: 1,888
Thanked 2,653 Times in 1,593 Posts
Groans: 55
Groaned at 35 Times in 32 Posts
|
Quote:
i'm an android LOL
__________________
click on 'Groan' to switch to my left testicle. |
|
|
|
|
![]() |
|
| Tags |
| maths, riddle |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|