[C++] Nested Radical Constant

做高数助教被天煞的大一学生坑了,发现是个未解问题,没有解析解。。

用C搞了下,就是这样。。。

No closed-form expression is known for this constant (Finch 2003, p. 8; S. Plouffe, pers. comm., Aug. 29, 2008).

/*****************************************
*@: Nested Radical Constant 嵌套根式常数
*@: http://mathworld.wolfram.com/NestedRadicalConstant.html
*****************************************/
#include "stdafx.h"
#include <stdio.h>
#include <math.h>
void main(void){
	int N = 10;
	int idx = 0;
	double an = 0;
	double temp = 0;

	an = sqrt(double(N));
	for(idx =(N-1);idx >= 1; idx--){
		temp = idx + an;
		an = sqrt(temp);
	}
	printf("N=%d,an=%f \n",N,an);
	getchar();
}

  

时间: 2024-11-10 07:59:47

[C++] Nested Radical Constant的相关文章

org.springframework.dao.InvalidDataAccessApiUsageException: detached entity passed to persist: sys.entity.Role; nested exception is org.hibernate.PersistentObjectException: 的解决方案

1.错误信息 org.springframework.dao.InvalidDataAccessApiUsageException: detached entity passed to persist: sys.entity.Role; nested exception is org.hibernate.PersistentObjectException: detached entity passed to persist: sys.entity.Role at org.springframew

简化条件表达式之以卫语句取代嵌套条件表达式(Replace Nested Conditional With Guard Clauses)

函数中的条件逻辑使人难以看清正常的执行途径.使用卫语句表现所有特殊情况. 动机:条件表达式通常有2种表现形式.第一:所有分支都属于正常行为.第二:条件表达式提供的答案中只有一种是正常行为,其他都是不常见的情况. 这2类条件表达式有不同的用途.如果2条分支都是正常行为,就应该使用形如if…..else…..的条件表达式:如果某个条件极其罕见,就应该单独检查该条件,并在该条件为真时立刻从函数中返回.这样的单独检查常常被称为“卫语句”. Replace Nested Conditional with

Spring Cloud ZooKeeper集成Feign的坑2,服务调用了一次后第二次调用就变成了500,错误:Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.n

错误如下: 2017-09-19 15:05:24.659 INFO 9986 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]56528192: startup date [Tue Sep 19 15:05:24 CST 2017]; root of context hierarchy 2017-09-19 15:05:24.858 INFO 9986 --

nested exception is java.sql.SQLException: IO 错误

1.错误描述 (mx.messaging.messages::ErrorMessage)#0 body = (null) clientId = "18CE3B03-9709-9DA8-7634-340C23317FDD" correlationId = "3161DF25-D056-D694-E5CF-963E4FE036D9" destination = "waitController" extendedData = (null) faultC

nested exception is java.io.FileNotFoundException: Could not open ServletContext resource

<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> 注意这段配置尽量写在靠前的位置,因为在tomcat启动后web项目会先初始化上下文,我们这段配置正是指定了上下文配置的文件位置,在上下文初始化完成之后才应当继

Sort merge join、Nested loops、Hash join(三种连接类型)

目前为止,典型的连接类型有3种: Sort merge join(SMJ排序-合并连接): 首先生产driving table需要的数据,然后对这些数据按照连接操作关联列进行排序:然后生产probed table需要的数据,然后对这些数据按照与driving table对应的连接操作列进行排序:最后两边已经排序的行被放在一起执行合并操作.排序是一个费时.费资源的操作,特别对于大表.所以smj通常不是一个特别有效的连接方法,但是如果driving table和probed table都已经预先排序

Angular之Providers (Value, Factory, Service and Constant )

官方文档Providers Each web application you build is composed of objects that collaborate to get stuff done.(每一个web应用都是由一些对象“组装”成的,这些对象共同合作,来完成特定的任务)These objects need to be instantiated and wired together for the app to work.(这些对象需要被实例化,然后“组装”在一起来使web应用能

Windows Server 2016 Hyper-v Nested Virtualization

Windows Server 2016 Hyper-v Nested Virtualization 在Windows Server 2016没有发布以前,作为屌丝的我们在没有太多物理机的情况下如果想要做Hyper-v群集的实验就必须使用VMWare Workstation的嵌套虚拟化技术! 但是随着Windows Server 2016的发布,微软已经允许我们在Hyper-v平台上使用嵌套虚拟化技术!嵌套虚拟化是一个允许我们在Hyper-v虚拟机中运行Hyper-v虚拟机的功能.换句话来说,通过

[LeetCode] Nested List Weight Sum II 嵌套链表权重和之二

Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- whose elements may also be integers or other lists. Different from the previous question where weight