Creating a textual version of an int to save as a C string to a buffer that is all ready allocated and maximum allowable size is determined seems common. Thought I'd make a function to fulfill that.
If the destination size is too small or destination is NULL, return NULL.
Your critique of func...
I was tasked by my teacher with making a LinkedList by myself, so I could understand the concept better. Here is the MyLinkedList class:
public class MyLinkedList<T>{
private Node<T> lastNode;
private int nodeCount;
public MyLinkedList(){
this.lastNode = null;
this.nodeCount = 0;
}
pub...
bonus points for asserting the wrong time complexity
@MichaelT :O
you monster
user55340
Consider the question of "what if you had to make fizz buzz for 1 .. 1_000_000_000 and handle arbitrary values passed in on command line" - fb 3:fizz 5:buzz 2025:qux
user55340
Now, incidentally, 2025 = 3^4 * 5^2
user55340
11:55 PM
But we could have 1665:baz in there too (37 * 5 * 3^2)
My take on it is that you collect the distinct prime factors of the problem space, and then find out the factors of the item in question.
user55340
1048950 is (the interesting parts) 37 * 5^2 * 3^4 (and 2 * 7, but we don't need to factor for those primes because they're not part of the problem space)
Implementation:
IEnumerable<BigInteger> Fibs()
{
BigInteger a = 0;
BigInteger b = 1;
while(true)
{
b = a + (a = b);
yield return a;
}
}
Usage:
void Main()
{
// take first 100 fib numbers
var fibs = Fibs().Take(100);
}
How can i improve this?