Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Babbage-problem/C/babbage-problem.c
Normal file
25
Task/Babbage-problem/C/babbage-problem.c
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// This code is the implementation of Babbage Problem
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
int main() {
|
||||
int current = 0, //the current number
|
||||
square; //the square of the current number
|
||||
|
||||
//the strategy of take the rest of division by 1e06 is
|
||||
//to take the a number how 6 last digits are 269696
|
||||
while (((square=current*current) % 1000000 != 269696) && (square<INT_MAX)) {
|
||||
current++;
|
||||
}
|
||||
|
||||
//output
|
||||
if (square>+INT_MAX)
|
||||
printf("Condition not satisfied before INT_MAX reached.");
|
||||
else
|
||||
printf ("The smallest number whose square ends in 269696 is %d\n", current);
|
||||
|
||||
//the end
|
||||
return 0 ;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue