We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #26: Reciprocal cycles
Project Euler #26: Reciprocal cycles
Sort by
recency
|
40 Discussions
|
Please Login in order to post a comment
is there a way to see the testcases inputs? I don't why my code is failing one of the test cases..
// c# using System;
public class Program { static int FindCycle(int n) { int[] seen = new int[n]; seen[1] = 1; int m = 1; int i = 2;
}
100% divide will calculate the reccurance , by long division method by dividing 100* > n
Explanation for this simple problem:
recurring_digits function: This function calculates the span of recurring digits in the decimal expansion of 1/n. It first removes factors of 2 and 5, then iteratively multiplies the remainder by 10 and takes the remainder after division by n until a recurring cycle is detected.
answers list: list is used to store the maximum recurring digit numbers for each index. It is initialized with four zeros, and the code iterates through numbers from 3 to 10^4 to populate this list.
Loop for finding maximum recurring digit numbers: The loop iterates through numbers from 3 to 10^4, calculates the recurring digits for each number using the recurring_digits function, and updates the maximum recurring digit number and count accordingly.
User input processing: The code then takes user input for the number of test cases and the specific values for which it needs to find the maximum recurring digit numbers. It prints the results accordingly.