Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // D solution to codabbey challenge 71
- import std.stdio;
- import std.array;
- import std.conv;
- pure int getidxfib(int mod) {
- int fib1 = 0;
- int fib2 = 1;
- int fib3 = 0;
- int idx = 2;
- while (true) {
- fib3 = (fib1 + fib2) % mod;
- if (fib3 % mod == 0){
- return idx;
- }
- fib1 = fib2;
- fib2 = fib3;
- idx++;
- }
- }
- void main() {
- static ncases = 19;
- int[19] cases = [449825, 940999, 891051, 674588, 241652, 1049193, 1024240, 857743, 408165, 641261, 349920, 1015891, 982578, 291607, 657942, 374884, 508055, 458138, 732856];
- string[19] RSP;
- string aux = "";
- for (int i = 0; i < RSP.length; i++){
- RSP[i] = to!string(getidxfib(cases[i]));
- }
- const string[] arr = RSP;
- //writeln(join(arr, " "));
- writeln(arr.join(" "));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement