Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I was looking through codes that generate a pascal triangle and every once in awhile I will see this formula :
a = (a* (x - y)/ (y + 1));

included in their code which I don't quite understand why it is there since it will produce out a value of 0 every time.

what does this formula really do to generate the triangle?

What I have tried:

Yes, I have tried it on my code and it works perfectly.
Posted
Updated 5-Feb-17 10:03am
Comments
PIEBALDconsult 5-Feb-17 15:45pm    
I can only suspect that it involves the oddities of integer mathematics.

1 solution

This formula by itself means nothing because variables values and code around matters.
You need to show code around.
Quote:
I don't quite understand why it is there since it will produce out a value of 0 every time.
What let you think it produce 0 every time ?
Using the debugger may help you to understand how this code work

hen you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. It allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.

Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900