Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main()
- {
- var a = Factorial();
- print(a.calc<int>(5));
- }
- class Factorial
- {
- T calc<T extends num>(T b)
- {
- num product=1;
- for(num i=b;i>0;i--)
- {
- product = product * i;
- }
- return product as T;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement