桃花长相依
#Q1f = c(1,1)for(i in 2:30) { print(sprintf("i=%i, f[i-1]=%i, f[i]=%i, f[i-1]/f[i]=%.4f", i, f[i-1], f[i], f[i]/f[i-1])) f=c(f, (f[i-1]+f[i])) # sum of last two element in f } 123456789101112131415161718192021# Q2. 每一步都打印出值,你可以参照一下> for ( j in 1:15) {+ print(sprintf("j=%i, answer[j]=%i, 7*answer[j]=%i, 7*answer[j]%%31=%i", j, answer[j], 7*answer[j], (7*answer[j])%%31))+ answer <- c(answer, ( 7* answer[ j ] ) %% 31)+ }[1] "j=1, answer[j]=3, 7*answer[j]=21, 7*answer[j]%31=21"[1] "j=2, answer[j]=21, 7*answer[j]=147, 7*answer[j]%31=23"[1] "j=3, answer[j]=23, 7*answer[j]=161, 7*answer[j]%31=6"[1] "j=4, answer[j]=6, 7*answer[j]=42, 7*answer[j]%31=11"[1] "j=5, answer[j]=11, 7*answer[j]=77, 7*answer[j]%31=15"[1] "j=6, answer[j]=15, 7*answer[j]=105, 7*answer[j]%31=12"[1] "j=7, answer[j]=12, 7*answer[j]=84, 7*answer[j]%31=22"[1] "j=8, answer[j]=22, 7*answer[j]=154, 7*answer[j]%31=30"[1] "j=9, answer[j]=30, 7*answer[j]=210, 7*answer[j]%31=24"[1] "j=10, answer[j]=24, 7*answer[j]=168, 7*answer[j]%31=13"[1] "j=11, answer[j]=13, 7*answer[j]=91, 7*answer[j]%31=29"[1] "j=12, answer[j]=29, 7*answer[j]=203, 7*answer[j]%31=17"[1] "j=13, answer[j]=17, 7*answer[j]=119, 7*answer[j]%31=26"[1] "j=14, answer[j]=26, 7*answer[j]=182, 7*answer[j]%31=27"[1] "j=15, answer[j]=27, 7*answer[j]=189, 7*answer[j]%31=3">