PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.27.5
Code Block Pro – Beautiful Syntax Highlighting v1.27.5
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / build / shiki / samples / v.sample

v.sample in Code Block Pro – Beautiful Syntax Highlighting 1.27.5, at build/shiki/samples/v.sample

38 lines 690 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // This program displays the fibonacci sequence
2 import os
3
4 fn main() {
5 // Check for user input
6 if os.args.len != 2 {
7 println('usage: fibonacci [rank]')
8
9 return
10 }
11
12 // Parse first argument and cast it to int
13
14 stop := os.args[1].int()
15 // Can only calculate correctly until rank 92
16 if stop > 92 {
17 println('rank must be 92 or less')
18 return
19 }
20
21 // Three consecutive terms of the sequence
22 mut a := i64(0)
23 mut b := i64(0)
24 mut c := i64(1)
25 println(a + b + c)
26 for _ in 0 .. stop {
27 // Set a and b to the next term
28 a = b
29 b = c
30 // Compute the new term
31 c = a + b
32
33 // Print the new term
34 println(c)
35 }
36 }
37
38 // From https://github.com/vlang/v/blob/master/examples/fibonacci.v