且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

挑战:一线上最短的Fibonacci序列算法

更新时间:2022-10-15 15:19:23

应该能够要做到这一点,虽然它的风格很糟糕。

int f = 0,t = 1;

这样的风格很糟糕,不管你的程序间距是多少。


c ++应该更短:

编辑...


可以通过改为for循环来缩短它:

int a = 1,b = 1; for(; b

此外,<必须< 4182如果你想要4181打印你的算法。


在C中,编译器不允许我在任何其他行中使用#include。

所以,不确定这是否可接受。每规则。
展开 | 选择 | Wrap | 行号


The challenge is to create the shortest algorithim, In any programming language.

RULES:
1. All code must be on one line.
2. Languages that prevent this are disallowed. I.E Assembly, and of course COBOL. All other languages are fair game.
3. Sequence must go up to at least 4181.


If i missed a languge that should be disallowed please let me know...
My solution is in Java. weighing in @ 108 Characters w/o spaces.

Expand|Select|Wrap|Line Numbers

should be able to do this, although it''s bad style.
int f=0,t=1;
It''s bad style not spacing your program out anyways.

c++ should be shorter:
editing...


Can make it even shorter by making it a for loop instead:
int a=1,b=1;for(;b<4182;a=b+(b=a))System.out.println(b );

Also, < has to be < 4182 if you want 4181 to print for your algorithm.


In C, the compiler will not let me use #include in the same line as any other.
So, not sure if this is "acceptable" per your rules.
Expand|Select|Wrap|Line Numbers


登录 关闭
扫码关注1秒登录
挑战:一线上最短的Fibonacci序列算法
发送“验证码”获取 | 15天全站免登陆
上一篇 : :如何使线穿过3D点云?下一篇 : 多音调使用portaudio到声卡

相关阅读

技术问答最新文章